I’m trying to get nested associations to work in 1.3 using cast_assoc like this article does Nested Associations & Changeset Errors in Ecto. However I’m stuck. In 1.2, using cast_assoc was pretty simple. Since each schema was its own module you could do it this way:
# Model A
def changeset(struct, params \\ %{}) do
struct
|> cast(params, @required_fields)
|> validate_required(@required_fields)
|> cast_assoc(:bs, required: true)
end
You could basically do this indefinitely with each model defining its changeset to cast it’s associations changeset. I can’t figure out how to do this with contexts in 1.3.