Looks like because the hidden field and the link don’t have the same
parent - the previous function finds you the previous sibling element
(matching the selector if specified)
I had to restructure my page in html so that the link did follow the
hidden input field. It works now but when I follow the further
instructions in the railscast to have an “add” link to add an object,
I get this error:
undefined method `render_partial’ for #<ActionView::ReloadableTemplate:
0x9f80d28>
this is my view:
<% echantillon_form.fields_for :treatments do |builder| %>
<%= render "treatment", :f => builder %>
<% end %>
<%= link_to_add_fields "Add treatment",