rubyonrailsin

A Ruby and Rails talk

Wednesday, March 24, 2010


[Rails] accessing object attributes

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

I have an hash of display names and their corresponding object
attribute names called @columns.
As I iterate through @columns, what is the syntax for accessing the
attribute of the object using c? I get an error on the 4th line.


<% for c in @columns["object_"+@object.categorie] do %>
<tr>
<td class="name"><%=c.first%></td>
<td><%= @object.c.second %></td>
</tr>

<% end %>

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

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive