Ruby on rails 未定义的方法“编辑注释路径”;(轨道)?
我有一个Post模型和一个Comment模型(它是第一个模型的嵌套资源): posts/show.html.erb:Ruby on rails 未定义的方法“编辑注释路径”;(轨道)?,ruby-on-rails,Ruby On Rails,我有一个Post模型和一个Comment模型(它是第一个模型的嵌套资源): posts/show.html.erb: <%= render @comments %> 我想我在这里有一些错误: comments/\u comment.erb <%= link_to "Edit Post Comment", [@post, edit_comment_path(comment)] %> 因为我得到了这个错误: undefined method `edit_comme
<%= render @comments %>
我想我在这里有一些错误:
comments/\u comment.erb
<%= link_to "Edit Post Comment", [@post, edit_comment_path(comment)] %>
因为我得到了这个错误:
undefined method `edit_comment_path' for #<#<Class:0xb439d8c>:0xaeaf4c0>
未定义的方法“编辑注释路径”
有什么建议可以解决这个问题吗?如果你运行
rake routes
你可以看到路由名称,在你的情况下,路由名称应该是edit\u post\u comment\u path
而不是edit\u comment\u path可能是
或
(未测试,不能在这里测试)
因为edit\u comment\u path
就像rails说的那样,是未定义的。rake routes
会给你答案我试过[@post,edit\u post\u comment\u path(comment)]
但是现在我得到了这个:未定义的方法
post\u posts/4/comments/2/编辑路径”。这就是我在路径中找到的:
edit\u post\u comment GET/posts/:post\u id/comments/:id/edit(:format)`将两个参数传递到路径:link\u到“edit post comment”,edit\u post\u comment\u path(@post,comment)
undefined method `edit_comment_path' for #<#<Class:0xb439d8c>:0xaeaf4c0>