Finally, it succeeded - the error occurred due to the fact that I used this stone in a slightly non-standard way. Within a form, instead of providing all sections of content in a standard way:
<%= f.fields_for :content_sections do |section_form| %>
I put it inside the loop, since I need the index of each element (which is not stored in the model itself):
<% page.content_sections.each_with_index do |section, index| %> <%= f.fields_for :content_sections, section do |section_form| %>
The problem with this is that the fields_for method fields_for not called if the association is empty, and therefore such a stone cannot build a project for an object (which is used to add an additional element when link_to_add ).
The solution was to make sure that fields_for received the call, even if the association is empty:
<% if page.content_sections.empty? %> <%= f.fields_for :content_sections do |section_form| %> # section fields <% end %> <% end %>
source share