我在我的数据库中有3条记录,我希望它们看起来像:如果我用于(每个)
<% @records.each do |record| %>
Run Code Online (Sandbox Code Playgroud)
Mat*_*eer 12
你可能想要each_with_index.就像是:
<% @records.each_with_index do |record, i| %>
<%= (i+1) %>. <%= record.foo %> <br />
<% end %>
Run Code Online (Sandbox Code Playgroud)
你可以使用each_with_index:
<% @records.each_with_index do |record, i| %>
#your code
<% end %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3592 次 |
| 最近记录: |