This question Check all associations before destroy in rails suggests using :dependent => :restrict.
Why do I get ArgumentError: Unknown key(s): dependent?
Does this work with has_and_belongs_to_many?
Why is there no mention in the docs? http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
Was it introduced after 3.0.7?
:dependent cannot be used with has_and_belongs_to_many. The docs you link to list the association methods that accept it: has_many, has_one and belongs_to.
You could add a before_remove hook and do your dependent check manually.
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