aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-05-12 14:11:15 -0400
committereileencodes <eileencodes@gmail.com>2014-05-13 20:56:34 -0400
commit05a90c36c55fe0e43d60c2d0aa09d7a16ddd34ee (patch)
tree7cede88865079ee2849f7cdfe0889dec8f7a9348 /activerecord/lib/active_record/associations/has_many_through_association.rb
parent1c851b8cdfba73066b4d6c045d9d228647635f98 (diff)
downloadrails-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/has_many_through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb8
1 files changed, 2 insertions, 6 deletions
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)