Embedded Records on a per-save basis


I’m using DS.EmbeddedRecordsMixin, DS.ActiveModelSerializer and the active_model_serializers gem on the backend with Rails.

I’m finding that with multiple levels of embedded records, and a complex application that allows editing of records from multiple places, it becomes extremely difficult to manage when records are embedded and when they are not.

I’m wondering if it might be easier to pas in which children you want to embed on every record.save() call.

I’d think the api looks something like this:

author.save({embed: ['posts', 'phoneNumbers']})

where author hasMany posts and phoneNumbers.

I’m not sure how this API would handle multiple levels of nested records, but wanted to open this approach up for discussion.