DV Dasari
DV Dasari

Reputation: 729

Display an array into multiple columns on the page

I have an array "$a" and the below code in my view displays all the elements in a single column. How do I display them into 5 columns?

<ul>  
 <% for w in $a %>    
   <%= w %><br/>
 <% end %>  
</ul>

Upvotes: 2

Views: 2873

Answers (1)

Sam 山
Sam 山

Reputation: 42865

See this question Display 5 records per row?

 <% @tags.in_groups_of(5).each do |tag_array| %>
      <% tag_array.each |tag| %>
      will output 5 tags here
      <% end %>
 <% end %>

Upvotes: 3

Related Questions