timcharper/calendar_date_select

Problem with nested form fields

Closed this issue · 2 comments

kamk commented

To reproduce:

<% form_for :user do |user_form|
      user_form.fields_for :user_dates do |dates_form| %>
  <%= dates_form.calendar_date_select :first_date %>
<% end %>
kamk commented

Just forgot one more closing <% end %> but it gives me error '@user[user_dates]' is not allowed as an instance variable name

just ran into the same issue after changing a relationship from has_many to has_one, I had

<% f.fields_for :scheduled_jobs do |sj_form| %>
  <%= sj_form.calendar_date_select :start_date %>
<% end %>

Turns out I forgot to update the fields_for, :scheduled_jobs should have been :scheduled_job. This resolved the issue for me.