路线
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时,列表实际上已被删除。
答案 0 :(得分:1)
如果您使用的是rails 4,则应将其作为数据属性传递
link_to "Delete", listing_path(@listing), :method => :delete, :data => {:confirm => 'Confirm Deletion'}
文档here