我正在尝试创建一个显示模型所有评论的提要。
_comments.html.erb
<% if @comments.any? %>
<ol>
<%= render partial: 'shared/comment_feed', collection: @comments %>
</ol>
<%= will_paginate @comments %>
<% else %>
<h2>Be the first one to comment on this episode!</h2>
<% end %>
_comment_feed.html.erb
<li id="<%= comment.id %>">
<%= link_to gravatar_for(comment.user), comment.user %>
<span class="user">
<%= link_to comment.user.name, comment.user %>
</span>
<span class="content"><%= simple_format comment.content %></span>
<span class="timestamp">
Posted <%= time_ago_in_words(comment.created_at) %> ago.
</span>
<% if current_user?(comment.user) %>
<%= link_to "delete", comment, method: :delete,
confirm: "Are you sure?",
title: comment.content %>
<% end %>
</li>
上面的代码给了我一个未定义的局部变量或方法“注释”错误。当使用部分渲染评论集合时,rails 不会自动生成评论吗?任何帮助将不胜感激。