Cast assoc changeset

I have this code It works fine for single assoc and gives me a single changeset. And with one transaction I update the entire record

       modell.changeset(records_struct, changeset_params)
        |> Ecto.Changeset.cast_assoc(assoc_model)
        |> Repo.update()

I have other associations I want to add to the Ecto.Changeset.cast_assoc(assoc_model). But I can’t figure out how?
I want it to make a one single changeset for all the associations like this

  modell.changeset(records_struct, changeset_params)
        |> Ecto.Changeset.cast_assoc(:model1, :model2))
        |> Repo.update()

Any ideas?
Thanks

What’s wrong with:

modell.changeset(records_struct, changeset_params)
|> Ecto.Changeset.cast_assoc(:model1))
|> Ecto.Changeset.cast_assoc(:model2))
|> Repo.update()

It can be chained.

1 Like