![](/img/trans.png)
[英]Why is this Rails 7 link_to destroy nested resource also trying to destroy the parent resource?
[英]Rails link_to destroy a nested resource?
我有一个嵌套的资源附件,我想创建一个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" %>
想法? 谢谢!
尝试
link_to "Delete Attachment", [@attachment.thread.project,@attachment.thread,@attachment], :confirm => "Are you sure?", :method => :delete
它有用吗?
您应该能够自己使用以下内容(删除:action =>'destroy'部分)。 此外,请求应该是DELETE请求,而不是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 %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.