From 22782e2cc131863b72e457636f9a995a6ae50136 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 14 Oct 2010 12:31:35 +0100 Subject: Fix bug in previous refactoring --- .../active_record/associations/through_association_scope.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb index 582474355e..c3f12fee2b 100644 --- a/activerecord/lib/active_record/associations/through_association_scope.rb +++ b/activerecord/lib/active_record/associations/through_association_scope.rb @@ -89,7 +89,7 @@ module ActiveRecord right_table_and_alias, table_aliases[left], left.primary_key_name, table_aliases[right], right.klass.primary_key, - polymorphic_conditions(left, left.options[:as]) + polymorphic_conditions(left, left) ) when :has_and_belongs_to_many raise NotImplementedError @@ -115,7 +115,7 @@ module ActiveRecord right_table_and_alias, table_aliases[left], left.source_reflection.primary_key_name, right_table, right.klass.primary_key, - polymorphic_conditions(left, left.source_reflection.options[:as]) + polymorphic_conditions(left, left.source_reflection) ) if right.macro == :has_and_belongs_to_many @@ -207,11 +207,11 @@ module ActiveRecord ] end - def polymorphic_conditions(reflection, interface_name) - if interface_name + def polymorphic_conditions(reflection, polymorphic_reflection) + if polymorphic_reflection.options[:as] "AND %s.%s = %s" % [ - table_aliases[reflection], "#{interface_name}_type", - @owner.class.quote_value(reflection.active_record.base_class.name) + table_aliases[reflection], "#{polymorphic_reflection.options[:as]}_type", + @owner.class.quote_value(polymorphic_reflection.active_record.base_class.name) ] end end -- cgit v1.2.3