diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association_scope.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb index 1001199daa..6f0f698f1e 100644 --- a/activerecord/lib/active_record/associations/through_association_scope.rb +++ b/activerecord/lib/active_record/associations/through_association_scope.rb @@ -144,7 +144,7 @@ module ActiveRecord end def build_sti_condition - @reflection.through_reflection.klass.send(:type_condition) + @reflection.through_reflection.klass.send(:type_condition).to_sql end alias_method :sql_conditions, :conditions diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 38a012202d..4a53a7bd22 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1622,14 +1622,12 @@ module ActiveRecord #:nodoc: o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)} end - def type_condition(table_alias = nil) - table = Arel::Table.new(table_name, :engine => active_relation_engine, :as => table_alias) - - sti_column = table[inheritance_column] + def type_condition + sti_column = active_relation_table[inheritance_column] condition = sti_column.eq(sti_name) subclasses.each{|subclass| condition = condition.or(sti_column.eq(subclass.sti_name)) } - condition.to_sql + condition end # Guesses the table name, but does not decorate it with prefix and suffix information. |