Why does :dependent => :restrict throw an error?

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.

Need Your Help

How do I use a third-party DLL file in Visual Studio C++?

c++ visual-studio winapi dll

I understand that I need to use LoadLibrary(). But what other steps do I need to take in order to use a third-party DLL file?

How to translate "default(SomeType)" from C# to CIL?

c# default cil

I'm currently working on a problem that involves System.Reflection.Emit code generation. I'm trying to figure out what CIL to emit in places where I would use default(SomeType) in C#.