Hey Guys,
i'm new on rails and started with the Rails Guide: Getting Started
with Rails
In section 7.4 I have a problem. I implemented the code as stated and
when I add a comment it works fine.
When I want to show the comment I get the following output under my
comment:
[#<Comment id: 1, commenter: "Tester", body: "This is a test comment",
post_id: 1, created_at: "2012-03-07 11:48:02", updated_at: "2012-03-07
11:48:02">]
<%= @my_object.comments.each do |comment| %>
.... # and then code to output the comment
<% end %>
rather than:
<% @my_object.comments.each do |comment| %>
.... # and then code to output the comment
<% end %>
The equals sign before the iterator will output to the browser the
result of the iterator (which will be the collection that's iterated).
You can see the Comment displayed has square brackets around it, which
indicate it's a single element array - so probably a collection that's
being rendered by mistake.