Permalink
Browse files

use attribute methods for finding key values rather than generating m…

…ethod names
  • Loading branch information...
tenderlove committed Jun 11, 2013
1 parent 9ca9ff3 commit e79fae55847506d138a3eca616b0c6e3ee560e26
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -55,10 +55,10 @@ def belongs_to_counter_cache_after_update(association, reflection)
if (@_after_create_counter_called ||= false)
@_after_create_counter_called = false
- elsif self.send("#{foreign_key}_changed?") && !new_record? && Object.const_defined?(name.to_s.camelize)
+ elsif attribute_changed?(foreign_key) && !new_record? && Object.const_defined?(name.to_s.camelize)
model = name.to_s.camelize.constantize
- foreign_key_was = self.send("#{foreign_key}_was")
- foreign_key = self.send foreign_key
+ foreign_key_was = attribute_was foreign_key
+ foreign_key = attribute foreign_key
if foreign_key && model.respond_to?(:increment_counter)
model.increment_counter(cache_column, foreign_key)

0 comments on commit e79fae5

Please sign in to comment.