Never been to DZone Snippets before?

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 (See related posts)

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>

Comments on this post

nagash_wa posts on Dec 05, 2006 at 10:48
Small nitpick..

<td><%= data.field unless data.nil? %></td>

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts