aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-02 14:38:05 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-02 14:38:05 -0700
commit5d8b7760ee3700c6d897e51e01dd2055da80506b (patch)
treee61be19c88552778b0193c997ec455f75757291c
parentc2b337183814cbd028407830509ce1da52e0e031 (diff)
downloadrails-5d8b7760ee3700c6d897e51e01dd2055da80506b.tar.gz
rails-5d8b7760ee3700c6d897e51e01dd2055da80506b.tar.bz2
rails-5d8b7760ee3700c6d897e51e01dd2055da80506b.zip
name is on the reflection, so just use the reflection
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb4
1 files 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)