My object is a Section. Each Section can have other Sections. Section responds to #index, index returns its order index. 0 if a section does not have sibling sections.
Let's assume my data structure is:
a
/ \
b c
Where:
a.index = 0
b.index = 0
c.index = 1
If I navigate to /sections/a/manage-child-ordering, I want to be able to edit the order of the subsections of a. This is the code in my view:
<% if @section.children %>
<%= form_for @section do |child| %>
<%= f.fields_for :children, @section.children do |c| %>
<%= c.text_field :index %>
<% end %>
<% end %>
<% end %>
<%= f.submit 'Save', class: 'btn-submit' %>
The error I get:
undefined method `errors' for #<Tag::ActiveRecord_Associations_CollectionProxy:0x007f23e60bdbd0>
What am I doing wrong?