Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Creating A Two Dimensional Table With Rails

DZone's Guide to

Creating A Two Dimensional Table With Rails

·
Free Resource
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.



  
   
<% @instance.in_groups_of(5) do |row| %>

   
      
<% row.each do |data| %>
        # The nil check is required because Rails pads empty table cells with nil.
	
     
<% end %>

     
<% end %>

   
<%= data.field unless data.nil? %>
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}