title: Rails nested form field counter
body: <p>I'm using <a href="https://github.com/ryanb/nested_form" rel="nofollow">https://github.com/ryanb/nested_form</a> 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</p>
  
  <p>The nested portion:</p>
  
  <pre><code>&lt;%= f.fields_for :instructions do |instruction| %&gt;
    &lt;%= instruction.label :"instruction #{instruction}" %&gt;
    &lt;%= instruction.text_field :instruction %&gt;
    &lt;%= instruction.link_to_remove "Remove this instruction" %&gt;
  &lt;% end %&gt;
  &lt;p&gt;
  &lt;%= f.link_to_add "Add instruction", :instructions, class: "btn btn-small btn-primary"  %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <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</p>