0

我有3个模型,,,,,,,如何user has many articles让用户的名字在他发布时出现在评论或文章中user has many commentsarticles belongs to usercomments belongs to user

<%= 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 %>
4

1 回答 1

1

您应该添加 a 也Comment属于User

然后:(<%= comment.user.name %>如果用户模型具有名称属性)

于 2013-05-11T15:00:19.093 回答