帖子中没有方法错误#show
我正在关注 Rails 入门教程: http://guides.rubyonrails.org/getting_started.html< /a> 而且代码和这里一样,我不明白。 我在第十行的“comments.post”中做错了什么?
NoMethodError in Posts#show
Showing /Users/franklinexpress/rails_projects/wal/app/views/comments/_comment.html.erb
其中第 10 行提出:
undefined method `post' for #<Comment:0x007ff05072c110>
提取的源代码(围绕第 10 行):
7: <b>Comment:</b>
8: <%= comment.comment %>
9: </p>
10: <%= link_to 'Destroy Comment', [comment.post, comment],
11: :confirm => 'Are you sure?',
12: :method => :delete %>
13:
I'm following the getting started rails tutorial at: http://guides.rubyonrails.org/getting_started.html
And the code is the same as here, I don't get it.
What am I doing wrong at "comments.post" in line ten?
NoMethodError in Posts#show
Showing /Users/franklinexpress/rails_projects/wal/app/views/comments/_comment.html.erb
where line #10 raised:
undefined method `post' for #<Comment:0x007ff05072c110>
Extracted source (around line #10):
7: <b>Comment:</b>
8: <%= comment.comment %>
9: </p>
10: <%= link_to 'Destroy Comment', [comment.post, comment],
11: :confirm => 'Are you sure?',
12: :method => :delete %>
13:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您拥有
7.2 关联模型
中的此内容,它应在
comment
实例上生成post
方法。Make sure you have this from
7.2 Associating Models
that should generate the
post
method on thecomment
instance.