diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 22:32:49 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-03-05 22:32:49 +0000 |
commit | b7f1b3641afe0ff4f3cd344815c6f7bb58821e9e (patch) | |
tree | 34558d5f8832fd7ddc37d1950bdb1600f5b27d97 /activerecord/lib/active_record/associations/join_dependency/join_association.rb | |
parent | 7fddb942624478a23173dfa379f7ade6a0fc9218 (diff) | |
download | rails-b7f1b3641afe0ff4f3cd344815c6f7bb58821e9e.tar.gz rails-b7f1b3641afe0ff4f3cd344815c6f7bb58821e9e.tar.bz2 rails-b7f1b3641afe0ff4f3cd344815c6f7bb58821e9e.zip |
Use Base#type_condition in JoinAssociation
Diffstat (limited to 'activerecord/lib/active_record/associations/join_dependency/join_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 5da3416023..fc8e75b10d 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -123,9 +123,11 @@ module ActiveRecord end conditions << table[key].eq(foreign_table[foreign_key]) - conditions << reflection_conditions(index, table) - conditions << sti_conditions(reflection, table) + + if reflection.klass.finder_needs_type_condition? + conditions << reflection.klass.send(:type_condition, table) + end ands = relation.create_and(conditions.flatten.compact) @@ -222,19 +224,6 @@ module ActiveRecord end end - def sti_conditions(reflection, table) - unless reflection.klass.descends_from_active_record? - sti_column = table[reflection.klass.inheritance_column] - sti_condition = sti_column.eq(reflection.klass.sti_name) - subclasses = reflection.klass.descendants - - # TODO: use IN (...), or possibly AR::Base#type_condition - subclasses.inject(sti_condition) { |attr,subclass| - attr.or(sti_column.eq(subclass.sti_name)) - } - end - end - end end end |