Thursday, May 13, 2010

Re: [Rails] to "loop through" the instance variables of ActiveRecord?

> to wrap each instance variable of an ActiveRecord object between "<td>"
> and "</td>", is there a way to "loop through" them, at least in the
> debug mode, no matter there is getter methods to get them or not, or at
> least the ones with the getter methods?
>
> Such as
>
> <% @stories.each do |s| %>
> <%= "<tr>" %>
> <% s.each_property do |i| %>
> <%= "<td>#{h i}</td>\n" %>
> <% end %>
> <%= "</tr>\n" %>
> <% end %>

@stories.attributes....

http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002348

-philip

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate