0
有帖子,评论和报告。报告属于评论(属于帖子)。我想在报告的展示页面上创建一条评论链接(连同它所属的帖子)。链接到评论错误
它应该是这个样子
... /职位/ 2 /评论/ 4
我有这个报告的显示页面,这给了我ID的评论。
<%= @report.comment.id %>
如何链接到报告展示页面上评论的展示页面?
有帖子,评论和报告。报告属于评论(属于帖子)。我想在报告的展示页面上创建一条评论链接(连同它所属的帖子)。链接到评论错误
它应该是这个样子
... /职位/ 2 /评论/ 4
我有这个报告的显示页面,这给了我ID的评论。
<%= @report.comment.id %>
如何链接到报告展示页面上评论的展示页面?
假如你已经被嵌套路由作为comments
内posts
,用于例如: -
resources :posts do
resources :comments
end
那么你将有路径post_comment_path
路由/posts/:post_id/comments/:id
。
在这种情况下,你可以有如下报告的节目页面上的链接,以评论的显示页面:
<%= link_to "Comment's Show Page" , post_comment_path(post_id: @report.comment.post.id, id: @report.comment.id) %>