DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Creating A Two Dimensional Table With Rails
This code creates a two dimensional table out of data passed from the controller. The code is pretty basic, but there's not much documentation on it.
<table> <% @instance.in_groups_of(5) do |row| %> <tr> <% row.each do |data| %> # The nil check is required because Rails pads empty table cells with nil. <td><%= data.field unless data.nil? %></td> <% end %> </tr> <% end %> </table>