diff options
author | eileencodes <eileencodes@gmail.com> | 2014-05-12 14:11:15 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2014-05-13 20:56:34 -0400 |
commit | 05a90c36c55fe0e43d60c2d0aa09d7a16ddd34ee (patch) | |
tree | 7cede88865079ee2849f7cdfe0889dec8f7a9348 /activerecord/lib/active_record/associations | |
parent | 1c851b8cdfba73066b4d6c045d9d228647635f98 (diff) | |
download | rails-05a90c36c55fe0e43d60c2d0aa09d7a16ddd34ee.tar.gz rails-05a90c36c55fe0e43d60c2d0aa09d7a16ddd34ee.tar.bz2 rails-05a90c36c55fe0e43d60c2d0aa09d7a16ddd34ee.zip |
rename delete_all_records to delete_or_nullify_all_records
Rename delete_all_records because this name better describes
what the method is doing. We can then remove :all from the
hm:t version and pull out the unoptimized call to load_target
in delete_records and pass it directly.
Diffstat (limited to 'activerecord/lib/active_record/associations')
3 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index d83019a920..caf4e612f9 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -194,7 +194,7 @@ module ActiveRecord options[:dependent] end - delete_all_records(dependent).tap do + delete_or_nullify_all_records(dependent).tap do reset loaded! end diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 8da543f3ff..4a7d8ed74a 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -113,7 +113,7 @@ module ActiveRecord end end - def delete_all_records(method) + def delete_or_nullify_all_records(method) count = delete_count(method, self.scope) update_counter(-count) end diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 5a45016cfa..35ad512537 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -130,17 +130,13 @@ module ActiveRecord end end - def delete_all_records(method) - delete_records(:all, method) + def delete_or_nullify_all_records(method) + delete_records(load_target, method) end def delete_records(records, method) ensure_not_nested - # This is unoptimised; it will load all the target records - # even when we just want to delete everything. - records = load_target if records == :all - scope = through_association.scope scope.where! construct_join_attributes(*records) |