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. Just watch out for the gotcha.
 
你是否曾经希望显示的条目能按行列对其呢?用in_groups_of 方法就能实现,来看一下吧.
------
这种情况:
List Task
task1
task2
task3
..
都按照一列排列下来。最好是一行4个,分成好几行,这样空间利用率高,而且美观。
 
<!-- 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>