I have a form that has fields with same name because of the "flow" of the form.
If the member is Undergrad:
<div id="if_undergrad">
<%= f.fields_for :academic do |academic_full_degree| %>
<%= academic_full_degree.text_field :major %>
<% end %>
</div>
But, if the member is Alumni:
<div id="if_alumni">
<%= f.fields_for :academic do |alumni| %>
<%= alumni.text_field :major %>
<% end %>
</div>
And I have a jQuery to show each div if the user selects alumni/undergrad from a drop-down.
If the member selects that he is Undergrad, Rails won't save the major into the database (I assume is because the major field of Alumni is blank).
Do you know how to make it work with the same name of fields?
Any help will be appreciated. Thank you!
params.require(:member).permit(:name, :academic_attributes => [:id])fields_forforms are exactly alike, why do you even have two of them? Why don't you just create one single form and use the same for both options Undergrad and Alumni?