But I use Ecto to normalize some parameters and returns that have nothing to do with the database (like returns from external APIs). This gives me confidence that I could move my persistence layer without that much change in my domain's boundaries.
I'm interested to hear how using embedded schemas backfired with you, though. :)
Basically, I'm presenting a schema that embeds two other schemas to use in a single form within Phoenix.HTML.Form.form_for/4. This schema is then translated into an Ecto.Multi for committing. However, if there's an error I lose some of the context when translating back from the Ecto.Multi from the schema-of-schemas.
Well, I usually don't :D
But I use Ecto to normalize some parameters and returns that have nothing to do with the database (like returns from external APIs). This gives me confidence that I could move my persistence layer without that much change in my domain's boundaries.
I'm interested to hear how using embedded schemas backfired with you, though. :)
Elixir Forum is back up, so I can link you directly to the issue.
Basically, I'm presenting a schema that embeds two other schemas to use in a single form within
Phoenix.HTML.Form.form_for/4
. This schema is then translated into anEcto.Multi
for committing. However, if there's an error I lose some of the context when translating back from theEcto.Multi
from the schema-of-schemas.This is all to work around what I see as a deficiency in the impl for Ecto.Changeset in Phoenix.HTML.FormData.form_for_errors/1. It doesn't play nicely with the error state for my construct.
There is likely a better way to do what I'm trying to do, but I'm still wrapping my head around this. :)