我有这样的想法:
<% if actions.include? "delete" %>
 <%= link_to 'Usuń', asset_path(asset), :method => :delete, :data => { :confirm =>   "Want to delete it?" }, :role => "link" %>
 <% end %>在assetcontroller中:
def destroy
@asset = current_user.assets.find(params[:id])
@asset.destroy
redirect_to assets_path
end问题是,当视图中的操作是“删除”时,为什么它“使用”销毁方法?
发布于 2013-06-25 18:53:33
delete是HTTP协议的方法。destroy是您的controller的action。使用delete HTTP方法的路由将导致destroy操作。
要编辑此路由并使delete HTTP方法导致delete操作(例如),您应该编辑config/routes.rb文件。
https://stackoverflow.com/questions/17295355
复制相似问题