diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-10-03 00:48:28 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-03 00:53:11 -0300 |
commit | 288885f9ebf07a12ce64bc3b4a73e9dbc27eeb40 (patch) | |
tree | a4cfdd016737fae00cb34a592012e479df263f64 /activerecord/lib/active_record | |
parent | 3f0bc97912482c2da9e70683b029feb36de74c27 (diff) | |
download | rails-288885f9ebf07a12ce64bc3b4a73e9dbc27eeb40.tar.gz rails-288885f9ebf07a12ce64bc3b4a73e9dbc27eeb40.tar.bz2 rails-288885f9ebf07a12ce64bc3b4a73e9dbc27eeb40.zip |
Refactor
Conflicts:
activerecord/lib/active_record/counter_cache.rb
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/counter_cache.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index 7d9b1b45b3..1ee465ab21 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -26,13 +26,11 @@ module ActiveRecord end if has_many_association.is_a? ActiveRecord::Reflection::ThroughReflection - foreign_key = has_many_association.through_reflection.foreign_key.to_s - child_class = has_many_association.through_reflection.klass - else - foreign_key = has_many_association.foreign_key.to_s - child_class = has_many_association.klass + has_many_association = has_many_association.through_reflection end + 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 && e.options[:counter_cache].present? } counter_name = reflection.counter_cache_column |