This question Check all associations before destruction in rails suggests using :dependent => :restrict.
:dependent => :restrict
Why am I getting ArgumentError: Unknown key(s): dependent?
ArgumentError: Unknown key(s): dependent
Does it work with has_and_belongs_to_many?
has_and_belongs_to_many
Why are there no references in the documents? http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
Was it introduced after 3.0.7?
:dependentcannot be used with has_and_belongs_to_many. The documents that you link, list the methods of association, which shall take it: has_many, has_oneand belongs_to.
:dependent
has_many
has_one
belongs_to
before_remove .
before_remove