How to do this?

Either the rails only way:


which pads with nil, or the more ruby way:

require 'enumerator'


Cheers, Max

Use in place of some_list.each. Instead of

<% for thing in list %> ... render stuff ... <% end %>


<% list.in_groups_of(2) do |two_things| %>   <tr>      <td><%= two_things[0].some_attribute if two_things[0] %></td>      <td><%= two_things[1].some_attribute if two_things[1] %></td>   </tr> <% end %>

The nil check is necessary, as in_groups_of pads the last "row" with nils if there are not enough elements in the list.

BTW, googling for "rails in_groups_of" would have gotten you there as well...

Cheers, Max