Here is our implementation: Dynamic embeds with Ecto · GitHub. It’s used in production and did not cause any issues yet. It’s very hacky though.
Notice that we explicitly call load_dynamic_embed/2 function every time schema is loaded from DB. We also dump everything to string-keyed map if changeset is valid to mimic behaviour of writing and reading from DB (so that you can compare user == inserted_user in test cases, otherwise string- and atom-keyed maps would be a problem).
If embedded changeset has an error it looks very much like nested schema was defined by using embeds_one/many`.






















