Search code examples
ruby-on-railsrubynested-attributesform-forfields-for

Twice nested attributes form_for


I am looking for a solution for a twice nested attributes form. The team has several player and each player has a few rounds. I added accept_nested_attributes in the models. This way did not worked for me.

 <% form_for(@team) do |team_fields| %>
     ...SOME FIELDS...
   <% team_fields.fields_for :players do |player_fields| %>...SOME FIELDS...

      <% player_fields.fields_for :rounds do |round_fields| %>
         <%= round_fields.text_field :message%>
      <%end%>
   <%end%>
 <%end%> 

Solution

  • Try printing your calls to .fields_for.

    <%= player_fields.fields_for :rounds do |round_fields| %>