From 5d8b7760ee3700c6d897e51e01dd2055da80506b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 2 Oct 2013 14:38:05 -0700 Subject: name is on the reflection, so just use the reflection --- activerecord/lib/active_record/associations/builder/belongs_to.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 4e88b50ec5..51d963e18d 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -34,7 +34,7 @@ module ActiveRecord::Associations::Builder mixin.class_eval do def belongs_to_counter_cache_after_create(association, reflection) - if record = send(association.name) + if record = send(reflection.name) cache_column = reflection.counter_cache_column record.class.increment_counter(cache_column, record.id) @_after_create_counter_called = true @@ -44,7 +44,7 @@ module ActiveRecord::Associations::Builder def belongs_to_counter_cache_before_destroy(association, reflection) foreign_key = reflection.foreign_key.to_sym unless destroyed_by_association && destroyed_by_association.foreign_key.to_sym == foreign_key - record = send association.name + record = send reflection.name if record && !self.destroyed? cache_column = reflection.counter_cache_column record.class.decrement_counter(cache_column, record.id) -- cgit v1.2.3