views:

12

answers:

1

In running through the basic rails tutorial section about outputting comments, I get the following displayed:

Comments

Commenter: Me

Comment: Hi

#<Comment:0x1052af610>

In the view I have:

<h2>Comments</h2>
<%= @post.comments.each do |comment| %>
<p>
  <b>Commenter:</b>
  <%= comment.commenter %>
</p>

<p>
  <b>Comment:</b>
  <%= comment.body %>
</p>
<% end %>

and in the controller I have:

class CommentsController < ApplicationController
  def create
    @post = Post.find(params["post_id"])
    @comment = @post.comments.create(params[:comment])
    redirect_to post_path(@post)
  end
end

So where is the bit: #<Comment:0x1052af610> coming from?

+2  A: 

Replace %= with % before @post.comments.each do |comment|

... but it's been a few years since I've used Rails, so I could be totally nuts.

novalis