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:
>
> <html>
> <body>
> <h1><%= @gallery.name -%></h1>
> <table>
> <%
> i = 1
> for img in @gallery.images
> -%>
> <%= if i == 1 || (i-1)%4 == 0
> "<tr>"
> else
> ""
> end -%>
> <td><img src='<%= img -%>'></td>
> <%= "</tr>" if i%4 == 0 -%>
> <%= i += 1
> "" -%>
> <% end -%>
> </table>
> </body>
> </html>
>
> 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