When I write:
belongs_to(:associate, Associate, foreign_key: :associate_id, on_replace: :nilify)
def do_associate(object, associated) do
object
|> put_assoc(:associate, associated)
|> Repo.update()
end
I have the impression that Repo.update
is called twice, once on the Object
, which makes totally sense, but also on Associate
, which from my point of view, doesn’t make sense to me, especially because the foreign key is owned by the Object
, hence nothing will change in the Associate
data.
Any reason for this? By any chance, can I avoid this issue?
Thanks