On 19 May 2010 13:59, the batman <[email protected]> wrote:
>
>> * you could (if you like it clunky) just use .each maintain your own
>> counter and do your next row operations when it gets to a multiple of
>> 3
>
> I think that's what I was trying to do, though I didn't know how to get
> a new table row
> was I on the right track?
I did try to hint that that was a poor option with all the Ruby
goodness available to you! :-)
Try:
<table>
<% @photos.each_slice(3) do |photos_row| %>
<tr>
<% photos_row.each do |photo| %>
<td><%= link_to image_tag(photo.image.url(:thumb)), photo %></td>
<% end %>
<% # could do with some check here to pad out row with blank
cells if any cell has less than three - to produce valid HTML
(wouldn't need to worry about this with CSS placement :-) %>
<tr/>
<% end %>
</table>
You could also pass the "<td>" drawing bit off to its own partial and
pass it the photos-row collection; but that might be one step too far
for you right now.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.