KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am stumped by this strange output in my Rails view. Here is my model: class Comment < ActiveRecord::Base belongs_to :post end Here is the relevant part of my view. I have isolated the problem to this block of code, specifically whatever happens after the last iteration and before the very end of the loop <% end %> . If I comment out the actual text printed in each iteration, the raw array still prints. <h2>Comments</h2> <%= @post.comments.each do |comment| %> <p> <strong>Commenter:</strong> <%= comment.commenter %> </p> <p> <%= comment.body %> </p> <% end %> Here is the strange output (w/ sample comments.): Commenter: Michael Good post. Commenter: Michael Good post. Commenter: Michael Test. Commenter: John Is the array still printing funny? [#<Comment id: 1, commenter: "Michael", body: "Good post.", post_id: 1, created_at: "2011-01-12 03:51:20", updated_at: "2011-01-12 03:51:20">, #<Comment id: 2, commenter: "Michael", body: "Good post.", post_id: 1, created_at: "2011-01-12 03:52:06", updated_at: "2011-01-12 03:52:06">, #<Comment id: 3, commenter: "Michael", body: "Test.", post_id: 1, created_at: "2011-01-12 03:52:24", updated_at: "2011-01-12 03:52:24">, #<Comment id: 4, commenter: "John", body: "Is the array still printing funny?", post_id: 1, created_at: "2011-01-12 03:57:20", updated_at: "2011-01-12 03:57:20">] Finally, here is how the development log is reading. They all look like this. Started GET "/posts/1" for 127.0.0.1 at 2011-01-11 22:01:52 -0600 Processing by PostsControll
Tags (comma-separated)
Save Edits
Cancel