From e4f6e6ad2d00cf2a205a405c18b4c7f284d153fd Mon Sep 17 00:00:00 2001 From: Aditya Sanghi Date: Sun, 22 May 2011 04:47:04 -0700 Subject: has_many :dependent => :restrict raises an exception but is not documented appropriately. has_one also has :dependent => :restrict but is not documented at all. --- activerecord/lib/active_record/associations.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d1752a25ff..2116a94980 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1077,7 +1077,8 @@ module ActiveRecord # alongside this object by calling their +destroy+ method. If set to :delete_all all associated # objects are deleted *without* calling their +destroy+ method. If set to :nullify all associated # objects' foreign keys are set to +NULL+ *without* calling their +save+ callbacks. If set to - # :restrict this object cannot be deleted if it has any associated object. + # :restrict this object raises an ActiveRecord::DeleteRestrictionError exception and + # cannot be deleted if it has any associated objects. # # If using with the :through option, the association on the join model must be # a +belongs_to+, and the records which get deleted are the join records, rather than @@ -1226,7 +1227,8 @@ module ActiveRecord # If set to :destroy, the associated object is destroyed when this object is. If set to # :delete, the associated object is deleted *without* calling its destroy method. # If set to :nullify, the associated object's foreign key is set to +NULL+. - # Also, association is assigned. + # Also, association is assigned. If set to :restrict this object raises an + # ActiveRecord::DeleteRestrictionError exception and cannot be deleted if it has any associated object. # [:foreign_key] # Specify the foreign key used for the association. By default this is guessed to be the name # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association -- cgit v1.2.3