I am trying to add dynamic fields to my rails application. I have a fields_for
<%= form.fields_for :books do |book| %>
<%= render 'book_fields', form: book %>
<% end %>
<%= link_to_add_fields "Add Field", form, :books %>
When it renders book_fields I am getting the following error
If I am passing form in render why would I be getting this error?
I have tried book.label :title but I get the same error but instead of the undefined varaible being form it is book. Any ideas? Thanks in advance.
UPDATE:
<%= form.fields_for :books do |builder| %>
<%= form.label :title %>
<%= form.text_field :title %>
<%= form.hidden_field :_destroy %>
<% end %>
If I remove the partial render and stick the form text fields and labels into the fields_for itself it works. While rendering the partial, that is when I get the error.
builder
insteadform
.