On Thu, Jan 20, 2011 at 2:04 PM, bourne <[email protected]> wrote:
> I have a bad feeling asking this but I did not manage to find an answer
> myself :/
>
> @comments = Comment.all
> @comments is an array.
> I can for example access comment.created_at directly, or I could do:
> <% @comments.each do |comment| %>
> <%= debug comment["created_at"] %>
> <% end %>
>
> I tried doing what you are doing and It works. Try this in the console:
Comment.all.each { |comment| puts comment["created_at"] }
Don't know what debug does, but the above code works.
> I expected comment to be a hash, but comment.keys or comment.values fail,
> as well as an each_pair approach.
> [I was actually trying to do a debug output printing all columns and
> columns names]
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.