Browse files

name is on the reflection, so just use the reflection

  • Loading branch information...
1 parent c2b3371 commit 5d8b7760ee3700c6d897e51e01dd2055da80506b @tenderlove tenderlove committed Oct 2, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/associations/builder/belongs_to.rb
View
4 activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -34,7 +34,7 @@ def add_counter_cache_methods(mixin)
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 @@ def belongs_to_counter_cache_after_create(association, reflection)
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)

0 comments on commit 5d8b776

Please sign in to comment.