I have the following:
has_many :people, :through => :roles
accepts nested_attributes_for :roles
(Roles and People are also correctly defined)
In my title#edit view, I have the fields_for set up correctly and working:
<%= f.fields_for :roles do |builder| %>
<%= render "role_fields", :f => builder %>
<%- end -%>
and in the role_fields partial, I have
<%= f.check_box :primary %>
<%= f.label :primary %>
Now I would like to change the check_box (which does work correctly) into a radio button, so only one of the nested roles would be the primary role. How can I use nested attributes and radio buttons?
If I replace the f.check_box call with f.radio_button( :primary, true ) I end up with a radio group that acts like a bunch of individual radio groups -- I can click on any of them and each one will check on without deselecting any of the others. If I change the name, so that each button has the same name, then the radio group works as expected, but the nested form breaks. I need those unique index names (title[roles_attributes][primary], title[roles_attributes][primary], title[roles_attributes][primary], etc.) to set the primary attribute on the correct nested role.
Thanks in advance,