I'm using https://github.com/ryanb/nested_form for my nested form. The nested form works fine, I'm now looking to have a sort of counter as I want to store the nested attributes in running number sequence. It should count+1 when a link_to_add is used and count-1 when link_to_remove
The nested portion:
<%= f.fields_for :instructions do |instruction| %>
<%= instruction.label :"instruction #{instruction}" %>
<%= instruction.text_field :instruction %>
<%= instruction.link_to_remove "Remove this instruction" %>
<% end %>
<p>
<%= f.link_to_add "Add instruction", :instructions, class: "btn btn-small btn-primary" %>
</p>
I'm thinking of using a variable to do a simple count, but i'm not sure how to trigger the increment. I've tried adding to the link_to_add, link_to_remove field but it stop with error. I'm still new to rails and pardon me if this a elementary question