Rails 6.1 added delegated_type which resembles polymorphic relations.
Using delegated_type the developer is introduced with a bunch of useful methods and scopes.
to know more about this feature.
For the sake of understanding,
let’s consider the following declaration of the Note model.
in order to create a new delegated_type record,
we would do something like this:
If we try to save the note using nested attributes,
it will raise an error:
With Rails 7 adding support of accepts_nested_attributes_for for delegated_type
we can save the records as follows:
To know more about this feature,