Skip to content

Instantly share code, notes, and snippets.

@noel
Created January 27, 2012 01:38
Show Gist options
  • Save noel/1686382 to your computer and use it in GitHub Desktop.
Save noel/1686382 to your computer and use it in GitHub Desktop.
Dynamic Table
<table id="roles">
<thead>
<tr>
<% @columns.each do |column| %>
<th class="center"><%= column %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @Roles.each_with_index do |role, index| %>
<% if index%2 == 0 %>
<tr>
<%else%>
<tr class="odd">
<% end %>
<% @columns.each do |column| %>
<td><%= role.send column %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment