Why: depend =>: restrict sending errors?

This question Check all associations before destruction in rails suggests using :dependent => :restrict.

Why am I getting ArgumentError: Unknown key(s): dependent?

Does it work with 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?

+3
source share
1 answer

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

before_remove .

+5

All Articles