diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 14:38:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 14:38:05 -0700 |
commit | 5d8b7760ee3700c6d897e51e01dd2055da80506b (patch) | |
tree | e61be19c88552778b0193c997ec455f75757291c /activerecord/lib | |
parent | c2b337183814cbd028407830509ce1da52e0e031 (diff) | |
download | rails-5d8b7760ee3700c6d897e51e01dd2055da80506b.tar.gz rails-5d8b7760ee3700c6d897e51e01dd2055da80506b.tar.bz2 rails-5d8b7760ee3700c6d897e51e01dd2055da80506b.zip |
name is on the reflection, so just use the reflection
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 4 |
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) |