<table>
<thead> <th colspan="2">Groups</th></thead>
<tbody>
<% for group in @groups %>
<tr>
<td><%= image_tag group.picture %></td>
<td>
<h6><%=link_to h(group.name), group %></h6>
<%= h group.description %>
</td>
</tr>
<% end %>
</tbody>
<tfoot><tr><td><%= will_paginate @groups%></td></tr></tfoot>
</table>
Refactorings
No refactoring yet !
nakajima
October 18, 2008, October 18, 2008 22:40, permalink
You can use a partial to clean this up a bit, though it doesn't seem totally bad as is.
<table>
<thead> <th colspan="2">Groups</th></thead>
<tbody>
<%= render :partial => "group", :collection => @groups %>
</tbody>
<tfoot><tr><td><%= will_paginate @groups %></td></tr></tfoot>
</table>
<tr>
<td><%= image_tag group.picture %></td>
<td>
<h6><%=link_to h(group.name), group %></h6>
<%= h group.description %>
</td>
</tr>
I need to make tables to list user, groups,... in my rails app. Below is such a table for groups (simplified).
The main difference between them is the table body. Is it possible to make a helper method to do this DRY?
Thanks in advance