ruby-on-rails – Rails link_to破坏嵌套资源?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rails link_to破坏嵌套资源?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个嵌套的资源附件,我想创建一个link_to来销毁/删除附件.这是我所拥有的,但它是作为GET与PUT发布的:
<%= link_to "Delete Attachment",project_thread_attachment_path(@attachment.thread.project.id,@attachment.thread.id,@attachment.id),:confirm => "Are you sure you want to delete this attachment?",:method => :delete,:action => "destroy" %>

想法?谢谢!

解决方法

您应该能够自己使用以下内容(删除:action =>’destroy’部分).此外,请求应该是DELETE请求,而不是PUT请求:
<%= link_to "Delete Attachment",:method => :delete %>
原文链接:https://www.f2er.com/ruby/273491.html

猜你在找的Ruby相关文章