From 4d7354aa352b94ec3a10ad053cff04890c534080 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 4 Dec 2018 14:33:31 +0900 Subject: Ensure that `delete_all` on collection proxy returns affected count Unlike the `Relation#delete_all`, `delete_all` on collection proxy doesn't return affected count. Since the `CollectionProxy` is a subclass of the `Relation`, this inconsistency is probably not intended, so it should return the count consistently. --- activerecord/lib/active_record/associations/has_many_association.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/active_record/associations/has_many_association.rb') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index e224d3456a..f6fdbcde54 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -99,6 +99,7 @@ module ActiveRecord def delete_or_nullify_all_records(method) count = delete_count(method, scope) update_counter(-count) + count end # Deletes the records according to the :dependent option. -- cgit v1.2.3