Ruby on rails 博客及其作者和评论者[如何让他们出现]

Ruby on rails 博客及其作者和评论者[如何让他们出现],ruby-on-rails,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3.2,我有3个模型,用户有很多文章,用户有很多评论,文章属于用户,评论属于用户,如何让用户的名字出现在评论或文章中 <%= div_for comment do %> <p><strong><%= %> says</strong></p> # how should i write a condition here to make the name of the commenter appear when he puts a

我有3个模型,
用户有很多文章
用户有很多评论
文章属于用户
评论属于用户
,如何让用户的名字出现在评论或文章中

<%= div_for comment do %>
  <p><strong><%=  %> says</strong></p> # how should i write a condition here to make the name of the commenter appear when he puts a comment
  <%= simple_format comment.content %>
<% end %>

#我应该如何在这里写一个条件,使评论者在发表评论时出现其姓名
您应该添加一条
注释
也属于
用户


然后:
(如果用户模型有name属性)

未定义的方法'user\u name'用于nil:NilClass提取的源代码(在第2行附近):1:2:表示

3:4:我没有足够的信息。粘贴到您的评论和用户模型中我找到了它,只是控制器中缺少了
@Comment.User\u id=current\u User.id
,我也为文章这么做了,谢谢您的帮助:D