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?
:dependentcannot be used withhas_and_belongs_to_many. The docs you link to list the association methods that accept it:has_many,has_oneandbelongs_to.You could add a
before_removehook and do your dependent check manually.