diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-09 15:31:09 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-09 15:31:09 -0800 |
commit | 12f67a70697212b55cde66f89ccd4caf0e9f4dad (patch) | |
tree | 6f630ffe49a44970681d2729dfdef946e246e660 /activerecord/lib | |
parent | 3e7c351b486356757631de9a89ea775c9bed658f (diff) | |
download | rails-12f67a70697212b55cde66f89ccd4caf0e9f4dad.tar.gz rails-12f67a70697212b55cde66f89ccd4caf0e9f4dad.tar.bz2 rails-12f67a70697212b55cde66f89ccd4caf0e9f4dad.zip |
use inject rather than lasgn
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb index 024ce4114b..5e37542416 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb @@ -121,14 +121,13 @@ module ActiveRecord # If the target table is an STI model then we must be sure to only include records of # its type and its sub-types. unless active_record.descends_from_active_record? - sti_column = target_table[active_record.inheritance_column] - + sti_column = target_table[active_record.inheritance_column] + subclasses = active_record.descendants sti_condition = sti_column.eq(active_record.sti_name) - active_record.descendants.each do |subclass| - sti_condition = sti_condition.or(sti_column.eq(subclass.sti_name)) - end - conditions << sti_condition + conditions << subclasses.inject(sti_condition) { |attr,subclass| + attr.or(sti_column.eq(subclass.sti_name)) + } end # If the reflection has conditions, add them |