← Graph

accepts_nested_attributes_for

concept 2 connections

Rails Active Record feature that lets a parent model declare accepts_nested_attributes_for :child, so a nested params hash (e.g. product with variant_attributes and nested size) automatically creates and assigns child records when saved. Works out of the box with Rails form helpers and supports deep nesting by declaring it on each intermediate model. Nick Sutterer's critique (motivation for Reform): it only really works when you have exactly one form per model — once you need different create/update/admin variants with different fields or validations, the model accumulates ifs/elses and validation contexts, quickly becoming unmaintainable.

category
pattern
about
accepts_nested_attributes_for concept
Origin story: Reform was created to replace accepts_nested_attributes_for for complex cases.
tool Reform
related_to
accepts_nested_attributes_for concept
Reform was motivated by the limitations of accepts_nested_attributes_for when more than one form per model is needed.

Provenance

Read by
1 extraction