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_"[email protected]] do %>
<tr>
<td class="name"><%=c.first%></td>
<td><%= @object.c.second %></td>
</tr>
<% end %>
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_"[email protected]] do %>
<tr>
<td class="name"><%=c.first%></td>
<td><%= @object.c.second %></td>
</tr>
<% end %>
It’s really hard for me to tell what you’re trying to do here. How about
we simplify and take it from there?
<% @columns.each do |key, value| %>
<%= key %> = <% value %>
<% end %>
Now, what is “@object” and how does it relate to the contents of
either ‘key’ or ‘value’?