Ok, Now I came to realize that there is an apparent answer.
I have changed the UserMeal Schema to this
schema "history_user_meals" do
field :meal_datetime, :utc_datetime
field :title, :string
field :user_id, :id
has_many :recipe_user_meals, RecipeUserMeal, on_replace: :delete
timestamps()
end
@doc false
def changeset(user_meal, attrs) do
user_meal
|> cast(attrs, [:title, :meal_datetime])
|> cast_assoc(:recipe_user_meals, with: &RecipeUserMeal.changeset/2)
|> validate_required([:title])
end
So that the cast_assoc only modifies the middle table and I am just using an additional preloading when returning objects.






















