You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model A which is non permanent which has_many :bs, dependent: :destroy. There is also a foreign key on B, called a_id, so I have referential integrity.
Now, of course, if I try to destroy an instance of A, this crashes, because my permanent B still exists when .destroy is called on it.
--- Caused by: ---
PG::ForeignKeyViolation:
ERROR: update or delete on table "A" violates foreign key constraint "fk_rails_feff868667" on table "B"
DETAIL: Key (id)=(589) is still referenced from table "B".
Is there a way to propagate the :force option down to the Bs? I know this is a very specific use case since I don't want to remove the referential integrity and indeed want to delete the otherwise permanent Bs, when I delete an A.
But since I saw that the reverse case, if A was permanent and B wasn't, is covered by this gem and documented in the specs, I thought I might ask. I didn't dig deep enough into the code yet to see if this is possible to achieve.
The text was updated successfully, but these errors were encountered:
I have a model A which is non permanent which
has_many :bs, dependent: :destroy
. There is also a foreign key on B, calleda_id
, so I have referential integrity.Now, of course, if I try to destroy an instance of A, this crashes, because my permanent B still exists when
.destroy
is called on it.Is there a way to propagate the
:force
option down to the Bs? I know this is a very specific use case since I don't want to remove the referential integrity and indeed want to delete the otherwise permanent Bs, when I delete an A.But since I saw that the reverse case, if A was permanent and B wasn't, is covered by this gem and documented in the specs, I thought I might ask. I didn't dig deep enough into the code yet to see if this is possible to achieve.
The text was updated successfully, but these errors were encountered: