我按照"入门" http://guides.rubyonrails.org/getting_started.html上的教程,并希望更改文章索引页面上的输出。
我希望看到有关该文章的最新评论,而不是在主表中显示该文章的文字。
以下是索引的代码:
<tr>
<td><%= article.title %></td>
<td><%= article.comments.select(:body).last %></td>
<td><%= link_to 'Show', article_path(article) %></td>
<td><%= link_to 'Edit', edit_article_path(article) %></td>
<td><%= link_to 'Destroy', article_path(article),
method: :delete,
data: { confirm: 'Are you sure?' } %></td>
</tr>
where&#39; article.comments.select(:body).last&#39;是为了显示有关该文章的最新评论的正文(该表针对每篇文章进行了迭代)。
然而,我没有看到评论中的文字,而是看到了这一点:
我也尝试在comments_controller中编辑comment.create:
@ article.text = @ comment.body
将索引表字段设置为&#39; article.text&#39; (工作正常),但没有效果。
任何人都知道我做错了什么? 非常感谢任何帮助。