Nested forms without accepts_nested_attributes_for in Rails | Rails Designer
16-Jan-2026 399
Build nested forms in Rails without accepts_nested_attributes_for. Use separate forms with auto-save and Turbo Streams for a simpler solution.Initially I thought of building it using Rails’ accepts_nested_attributes_for (like I wrote about here), but I quickly opted out of that and instead had a simpler idea for it. Some ideas are so simple that I feel almost embarrassed to publish about it. But over the years I’ve found that the most simple ideas will still delight plenty of people.
So here is a way to have “nested forms” in Rails without accepts_nested_attributes_for.
As often is the case, the code can be found on GitHub. It doesn’t look as polished as the example in the Gif above, but it uses essentially the same logic under the hood.
Start with the basic models. A Form has many Fields. Each field uses Single Table Inheritance (STI) to handle different field types:.
Nested forms without accepts_nested_attributes_for in Rails | Rails Designer #ruby #rubydeveloper #rubyonrails #Nested #forms #without #accepts_nested_attributes_for #Rails #Rails #Designer https://rubyonrails.ba/link/nested-forms-without-accepts_nested_attributes_for-in-rails-rails-designer