diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2013-05-13 11:39:09 -0400 |
---|---|---|
committer | Neeraj Singh <neerajdotname@gmail.com> | 2013-05-13 11:39:09 -0400 |
commit | 7b24cf0391ed8916bf12781a179b4ac5995e1690 (patch) | |
tree | 46769181104f7b92410913beeaf60b9c38e680cc | |
parent | d790b50db4b0e605a915b4a4af5f81acae7b6094 (diff) | |
download | rails-7b24cf0391ed8916bf12781a179b4ac5995e1690.tar.gz rails-7b24cf0391ed8916bf12781a179b4ac5995e1690.tar.bz2 rails-7b24cf0391ed8916bf12781a179b4ac5995e1690.zip |
emphasize that callbacks are called in destroy_all
Cleaned up rdoc a bit emphasizing that callbacks are called. Also
removed the stress on the fact that records are always removed.
If callbacks return false then records will not be deleted.
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 2a00ac1386..efd7ecb97c 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -237,11 +237,11 @@ module ActiveRecord end end - # Destroy +records+ and remove them from this association calling - # +before_remove+ and +after_remove+ callbacks. + # Deletes the +records+ and removes them from this association calling + # +before_remove+ , +after_remove+ , +before_destroy+ and +after_destroy+ callbacks. # - # Note that this method will _always_ remove records from the database - # ignoring the +:dependent+ option. + # Note that this method removes records from the database ignoring the + # +:dependent+ option. def destroy(*records) records = find(records) if records.any? { |record| record.kind_of?(Fixnum) || record.kind_of?(String) } delete_or_destroy(records, :destroy) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 71b64de5ea..e82c195335 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -422,9 +422,9 @@ module ActiveRecord @association.delete_all end - # Deletes the records of the collection directly from the database. - # This will _always_ remove the records ignoring the +:dependent+ - # option. + # Deletes the records of the collection directly from the database + # ignoring the +:dependent+ option. It invokes +before_remove+, + # +after_remove+ , +before_destroy+ and +after_destroy+ callbacks. # # class Person < ActiveRecord::Base # has_many :pets |