[Rails] each 使用 index
使用方式
<% @groups.to_enum.each.with_index(1) do |group, index| %>
<tr>
<td><%= index %></td>
</tr>
<% end %>
參考
- http://stackoverflow.com/questions/5646390/ruby-each-with-index-offset
<% @groups.to_enum.each.with_index(1) do |group, index| %>
<tr>
<td><%= index %></td>
</tr>
<% end %>
參考
- http://stackoverflow.com/questions/5646390/ruby-each-with-index-offset
留言