为什么确认框不起作用?

时间:2014-11-24 20:04:22

标签: ruby-on-rails

路线

  resources :listings do
 member do
   post :leadcreate
   post :storycreate
 end

控制器操作

  def destroy
    @listing = Listing.find(params[:id])
    @listing.destroy
    redirect_to 'root_path', :notice => "Listing Successfully Deleted"
  end

查看

 <%= link_to "Delete", listing_path(@listing), :confirm => "Confirm Deletion", :method => :delete %>

错误

它只是转到“No Data Received”页面,然后当我刷新并返回root时,列表实际上已被删除。

1 个答案:

答案 0 :(得分:1)

如果您使用的是rails 4,则应将其作为数据属性传递

link_to "Delete", listing_path(@listing), :method => :delete, :data => {:confirm => 'Confirm Deletion'}

文档here