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.
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.