![](/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.