I have a class :klass that has_many :otherklass, and it's dependent: :destroy.
However, when I try to destroy a :klass, rails is looking for otherklass.namespace_klass_id = klass.id, and understandably not finding anything.
Is there a way to tell rails explicitly that :otherklass uses .namespace_klass_id as the column on otherklass?
After some more searching, a coworker and I found that the answer is adding:
foreign_key: :namespace_klass_id
So it looks like:
has_many :otherklass, foreign_key: :namespace_klass_id, dependent: :destroy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With