I'm a React and RoR enthusiast with over two years of experience creating innovative software solutions that improve business productivity. I work well in teams and am always up for challenging projects. Born and raised in Pune, I enjoy cooking, painting and travelling in my free time.
1 minute read
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,