diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 15691e26dfc43f44209c42e68297dee32e7f4fda..f936bcb80e0bc8631b64f655d7c5273ca339527b 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -4,7 +4,7 @@ class AssociationScope #:nodoc: attr_reader :association, :alias_tracker delegate :klass, :reflection, :to => :association - delegate :chain, :scope_chain, :to => :reflection + delegate :chain, :to => :reflection def initialize(association) @association = association @@ -16,7 +16,7 @@ def scope scope.extending! Array(reflection.options[:extend]) owner = association.owner - add_constraints(scope, owner) + add_constraints(scope, owner, reflection.scope_chain) end def join_type @@ -61,7 +61,7 @@ def bind(scope, table_name, column_name, value) bind_value scope, column, value end - def add_constraints(scope, owner) + def add_constraints(scope, owner, scope_chain) tables = construct_tables chain.each_with_index do |reflection, i|