{:ok, existing_profile} = TestRepo.insert(%Profile{name: "profile"})
changeset =
%Author{}
|> Changeset.change()
|> Changeset.put_assoc(:profile, existing_profile)
# currently returns false however it is clearly changed
Changeset.changed?(changeset, :profile)
changeset =
%Author{profile: existing_profile}
|> Changeset.change()
|> Changeset.put_assoc(:profile, nil)
# currently crashes
Changeset.changed?(changeset, :profile)
{:ok, existing_profile} = TestRepo.insert(%Profile{name: "profile"})
changeset =
%Author{}
|> Changeset.change()
|> Changeset.put_assoc(:profile, existing_profile)
# should return true
Changeset.changed?(changeset, :profile) == true
changeset =
%Author{profile: existing_profile}
|> Changeset.change()
|> Changeset.put_assoc(:profile, nil)
# should return true
Changeset.changed?(changeset, :profile) == true