From: Justin Collins Date: 2006-08-02T08:17:29+09:00 Subject: Re: Rails view template for a gallery stephen O'D wrote: > I am totally new to rails, so sorry for the trivial question! > > I have an object, gallery, that contains a list of images. I want to > display these images in a table with 4 columns and as many rows as it > takes, closing the final table row at the end. > > What is the best way todo this? > > I can do it (mostly, the final table row is still left open) using the > following template, but it seems a bit hackish in places: > > > >

<%= @gallery.name -%>

> > <% > i = 1 > for img in @gallery.images > -%> > <%= if i == 1 || (i-1)%4 == 0 > "" > else > "" > end -%> > > <%= "" if i%4 == 0 -%> > <%= i += 1 > "" -%> > <% end -%> >
> > > > Is there a better way? > Generally, you'll want to ask Rails-specific questions on the Rails mailing list, as this is the Ruby mailing list. http://lists.rubyonrails.org/mailman/listinfo/rails -Justin