Picture Grid View

Hi,

I am trying to show pictures (adverts) in a grid. I want to show 3
pictures across and 3 pictures down. How would I do this.

Here is my view code:

<% for advert in @userAdverts %>

<% end %>

<%= image_tag url_for_file_column(advert, "image","thumb") unless url_for_file_column(advert, "image","thumb").nil?%>
  <br><span class="ListTitle"><b><%= link_to h(advert.title), 

:action => ‘show’, :id => advert %>

<%= h(truncate(advert.description, 80)) %>


<%= sprintf("$%0.2f", advert.price)unless
advert.price=0.0%>

David S. wrote:

Hi,

I am trying to show pictures (adverts) in a grid. I want to show 3
pictures across and 3 pictures down. How would I do this.

Here is my view code:

<% for advert in @userAdverts %>

<% end %>

<%= image_tag url_for_file_column(advert, "image","thumb") unless url_for_file_column(advert, "image","thumb").nil?%>
  <br><span class="ListTitle"><b><%= link_to h(advert.title), 

:action => ‘show’, :id => advert %>

<%= h(truncate(advert.description, 80)) %>


<%= sprintf(“$%0.2f”, advert.price)unless
advert.price=0.0%>

If you on edge (I think it only edge) Array#in_groups_of is your friend
http://caboo.se/doc/classes/ActiveSupport/CoreExtensions/Array/Grouping.html#M004481

<% @items.in_groups_of(3).each do |item_group| %> <% item_group.each do |item| %> <%= item.title %> <% end %> <% end %>