在Rails视图中的users / index.html.erb
我遍历每个用户列出所有用户。
想序列号。在用户列表前面。我使用each_with_index
来实现这一目标。
我想知道rails是否提供了更好的替代方案。我正在使用rails 4.1
<% @users.each_with_index do |user,count| %>
<tr>
<td><%= count+1 -%></td>
<td><%= user.name %></td>