cocoon: undefined method `label' for false:FalseClass
Hello, something is wrong on my side…
I used cocoon for other projects and has no such problem:
undefined method 'label' for false:FalseClass
I am using regular rails form with fields_for:
<%= form_for [:admin, @phone_num], html: { class: 'form-horizontal' } do |f| %>
<%= f.fields_for :email_addresses do |ea| %>
<%= render 'email_address_fields', ea: ea %>
<div class='col-md-12 links'>
<%= link_to_add_association 'Add Email Address', f, :email_addresses %>
</div>
<% end %>
<% end %>
And the partial:
<%= ea.label :address, class: 'control-label col-md-2' %>
<%= ea.email_field :address, class: 'form-control required' %>
<%= link_to_remove_association 'Remove address', ea %>
the error occur on first line of partial… 😕 What is wrong here ?
Rails 5.1.2 cocoon (1.2.11)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (1 by maintainers)
Hi @nathanvda , thanks for stepping in ! You right, I moved it outside of loop of
fields_for
but still the issue.But once i set
form_name: 'ea'
its worked 😃I totally missed this… and the
form_name
.Thank you @Mirv and @nathanvda for your help !
Hi @alexey, so looking at the top of the question, everything is looking pretty good at first.
Except you are using a different
form_name
for your partial, and I am guessing this is causing the error. Secondly you write yourlink_to_add_association
inside thefields_for
loop which will show a link for each nested item, and not show a link if there are no nested items, so to solve those two problems you could write: