How do you pass multiple arguments to nested route paths in Rails?

折月煮酒 提交于 2019-12-05 09:58:09

I think your route would be something like articles/:article_id/comments/:id so you can do:

<%= link_to "Delete", article_comments_path(article_id: comment.article_id, id: comment.id), method: :delete, data:{comfirm: 'Are you sure?'} %>

And your 3rd link should be

<%= link_to 'Destroy Comment', polymorphic_path(comment.article, comment), method: :delete, data: { confirm: 'Are you sure?' } %>

For details check Polymorphic routes

Update

You just need to pass locals to your partial like:

<%= render "comment", locals: {article: comment.article, comment: comment} %>

and then use

<%= link_to "Delete", article_comments_path(article.id,comment.id), method: :delete, data:{comfirm: 'Are you sure?'}%>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!