Going through an array in batches...

Hi,

Im looking to display my products in a table so that they show up as:

X-X-X-X
X-X-X-X
X-X-X…

I have my @products but how can I loop it so that for every 4 (or N)
products I can insert a new

to close the previous and open a

new row?

#in_groups_of

http://weblog.rubyonrails.org/2006/3/1/new-in-rails-enumerable-group_by-and-array-in_groups_of

<% @products.in_groups_of(4) do |row| %>

<% row.each do |product| %> <%= [product.name](http://product.name) %> <% end %> <% end -%>

Matt

Hi --