bourne wrote in post #976264:
> 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 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]

Is Comment an ActiveRecord subclass?  If so, then its instances aren't 
hashes.  Check out the docs for ActiveRecord::Base; the attributes 
method may be particularly useful.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

-- 
Posted via http://www.ruby-forum.com/.

-- 
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.

Reply via email to