I have a big collection of items I want to display two columns of
ordered lists. I'm pretty new to RoR, but I think there must be some
way to do this with a helper.
this is the code i want to split
<ol>
<% @items.each do |item| %>
<li><a href="<%= item.id %>"><%= item.name %></a></li>
<% end %>
</ol>
I have a big collection of items I want to display two columns of
ordered lists. I'm pretty new to RoR, but I think there must be some
way to do this with a helper.
this is the code i want to split
<ol>
<% @items.each do |item| %>
<li><a href="<%= item.id %>"><%= item.name %></a></li>
<% end %>
</ol>
Quoting...
in_groups_of
Have you ever wanted to visually line up items in rows and columns? The in_groups_of method makes this a cinch.
<!-- tasks/index.rhtml -->
<table>
<% @tasks.in_groups_of(4, false) do |row_tasks| %>
<tr>
<% for task in row_tasks %>
<td><%= task.name %></td>
<% end %>
</tr>
<% end %>
</table>