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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Javier Quarite at Mar 8, 2012 at 7:38 am
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Michael Pavling at Mar 8, 2012 at 8:16 am

    On 7 March 2012 12:04, NoobyOnRails 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • NoobyOnRails at Mar 8, 2012 at 9:16 am

    On 8 Mrz., 09:15, Michael Pavling 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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMar 8, '12 at 7:32a
activeMar 8, '12 at 9:16a
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase