diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-14 12:31:35 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-14 12:31:35 +0100 |
commit | 22782e2cc131863b72e457636f9a995a6ae50136 (patch) | |
tree | dc97f7de56a5f1d0867a2acdd819eebc1ba49657 | |
parent | 3fb493c2b037ffbdda5c91d66334ec6f79faa2d1 (diff) | |
download | rails-22782e2cc131863b72e457636f9a995a6ae50136.tar.gz rails-22782e2cc131863b72e457636f9a995a6ae50136.tar.bz2 rails-22782e2cc131863b72e457636f9a995a6ae50136.zip |
Fix bug in previous refactoring
-rw-r--r-- | activerecord/lib/active_record/associations/through_association_scope.rb | 12 |
1 files changed, 6 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 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 |