I am trying to create a feed that displays all comments for a model.
_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>
The above code gives me an undefined local variable or method `comment' error. Doesn't rails automatically generate comment when a partial is used to render comments collections? Any help would be greatly appreciated.