diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-21 14:10:33 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-21 14:36:04 -0300 |
commit | 648c5a1369ed64608c3ca43a5ebc917687d20010 (patch) | |
tree | 834ad77d7aec2718cb6148e6ec6cd0a42a9012fc /activerecord/lib/active_record/counter_cache.rb | |
parent | c091fae21f32250b19475f124c3b680dbbc163d9 (diff) | |
download | rails-648c5a1369ed64608c3ca43a5ebc917687d20010.tar.gz rails-648c5a1369ed64608c3ca43a5ebc917687d20010.tar.bz2 rails-648c5a1369ed64608c3ca43a5ebc917687d20010.zip |
Merge pull request #5210 from Pliny/masteri
Fix for #5200
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/counter_cache.rb
Diffstat (limited to 'activerecord/lib/active_record/counter_cache.rb')
-rw-r--r-- | activerecord/lib/active_record/counter_cache.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index ee0b0c7fab..0ba54e6248 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -28,7 +28,7 @@ module ActiveRecord foreign_key = has_many_association.foreign_key.to_s child_class = has_many_association.klass belongs_to = child_class.reflect_on_all_associations(:belongs_to) - reflection = belongs_to.find { |e| e.foreign_key.to_s == foreign_key } + reflection = belongs_to.find { |e| e.foreign_key.to_s == foreign_key && e.options[:counter_cache].present? } counter_name = reflection.counter_cache_column stmt = unscoped.where(arel_table[primary_key].eq(object.id)).arel.compile_update({ |