NoobyOnRails
2012-Mar-07 12:04 UTC
[Rails Guides] Getting Started 7.4 - Array Output Problem
Hey Guys, i''m new on rails and started with the Rails Guide: Getting Started with Rails http://guides.rubyonrails.org/getting_started.html 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">] Can somebody tell me where this come from? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Javier Quarite
2012-Mar-08 07:37 UTC
Re: [Rails Guides] Getting Started 7.4 - Array Output Problem
Could you post the code of the show.html.erb? (because you''re saying that it happens in the "show" action) Javier Q. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2012-Mar-08 08:15 UTC
Re: [Rails Guides] Getting Started 7.4 - Array Output Problem
On 7 March 2012 12:04, NoobyOnRails <satchillananda-S0/GAf8tV78@public.gmane.org> wrote:> 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">]You''re possibly doing this: <%= @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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
NoobyOnRails
2012-Mar-08 09:16 UTC
Re: [Rails Guides] Getting Started 7.4 - Array Output Problem
On 8 Mrz., 09:15, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''re possibly doing this: > > <%= @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 %>Thats the point! Thank you so much! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.