aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-22 16:12:24 +0900
committerGitHub <noreply@github.com>2018-01-22 16:12:24 +0900
commit109505843ff74585c2c30e3b187bced56ff3a08a (patch)
tree46fcd585cccd797240adeed02ed74e6de0ddfe59 /activerecord/lib
parentebc28aa74af410c590534140cc4e4bd0b69a045a (diff)
parent3e71bc4b048bef2ae7723dde5082020fd984bbd6 (diff)
downloadrails-109505843ff74585c2c30e3b187bced56ff3a08a.tar.gz
rails-109505843ff74585c2c30e3b187bced56ff3a08a.tar.bz2
rails-109505843ff74585c2c30e3b187bced56ff3a08a.zip
Merge pull request #31710 from eugeneius/indestructible_through_record
Don't update counter cache when through record was not destroyed
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb2
1 files changed, 1 insertions, 1 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 7a3bef969b..24766dd315 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -145,7 +145,7 @@ module ActiveRecord
case method
when :destroy
if scope.klass.primary_key
- count = scope.destroy_all.length
+ count = scope.destroy_all.count(&:destroyed?)
else
scope.each(&:_run_destroy_callbacks)
count = scope.delete_all