提交 e79fae55 编写于 作者: A Aaron Patterson

use attribute methods for finding key values rather than generating method names

上级 9ca9ff3f
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册