通过 form 结合 fields_for 可以实现迭代。 请问如何获取迭代中显示序号……
<%= f.fields_for :line_items do |line| %>
#how to get the index <%end %>
<% @line_items.each_with_index do |v, i|%> <%= f.fields_for :line_items do |line| %> <%= i %> # the index you want <%end %> <% end %>