undefined local variable or method `form' for #<#<Class:0x00007fc295dd38d0>:0x00007fc2969e7338>
_form.html.erb
<%= form.label :parent_1_firstname %>
</div>
<div class="col-sm-8">
<%= form.text_field :parent_1_firstname, class: "form-control", placeholder: "Parent 1 first name", autofocus:true %>
</div>
</div>
<div class = "form-group">
<div class="control-label col-sm-2">
<%= form.label :parent_1_lastname %>
</div>
<div class="col-sm-8">
<%= form.text_field :parent_1_lastname, class: "form-control", placeholder: "Parent 1 last name", autofocus:true %>
</div>
</div>
<div id = 'secondaryparents'>
<%= form.fields_for :secondaryparents do |builder| %>
<%= render 'secondaryparent_fields', :form => builder %>
<% end %>
<%= link_to_add_association 'Add Secondary Parent', form, :secondaryparents %>
</div>
<div class = "form-group">
<div class="control-label col-sm-2">
<%= form.label :address %>
</div>
<div class="col-sm-8">
<%= form.text_area :address, class: "form-control", placeholder: "Address", autofocus:true %>
</div>
</div>
<div class="col-sm-8">
<%= form.text_area :address, class: "form-control", placeholder: "Address", autofocus:true %>
</div>
</div>
_secondaryparent_fields.html.erb
I am facing this. Please help undefined local variable or method `form' for #<#Class:0x00007fc295dd38d0:0x00007fc2969e7338>
Is this not the same as #495
In the link_to_add_association you will have to specify the form_name as follows:
link_to_add_association 'Add Secondary Parent', form, :secondaryparents, form_name: 'form'
@nathanvda thankyou so much
Hello i got the same issue ... em i did form_name: 'form' and nothing if i put form_name: 'f' i get the same error. @nathanvda
Hi @ricardosikic can you open a new issue with your code please?
In the
link_to_add_associationyou will have to specify theform_nameas follows:link_to_add_association 'Add Secondary Parent', form, :secondaryparents, form_name: 'form'
thanks dude