1
我想創建一個顯示模型的所有註釋的源。軌道渲染集合不工作 - 未定義的本地變量或方法
_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是否會自動生成註釋?任何幫助將不勝感激。
工作就像一個魅力。謝謝。 – jeebface 2013-03-01 03:25:08