From db3f50c767f3933a43c23ec3a7b9ef02668d048a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Feb 2014 14:04:39 -0800 Subject: [PATCH] clean up add_constraints signature --- .../associations/association_scope.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 2046d94a3d..9590d28129 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -9,15 +9,13 @@ module ActiveRecord end def scope - klass = association.klass + klass = association.klass reflection = association.reflection - scope = klass.unscoped - scope.extending! Array(reflection.options[:extend]) + scope = klass.unscoped + owner = association.owner - owner = association.owner - scope_chain = reflection.scope_chain - chain = reflection.chain - add_constraints(scope, owner, scope_chain, chain, klass, reflection) + scope.extending! Array(reflection.options[:extend]) + add_constraints(scope, owner, klass, reflection) end def join_type @@ -62,7 +60,10 @@ module ActiveRecord bind_value scope, column, value end - def add_constraints(scope, owner, scope_chain, chain, assoc_klass, refl) + def add_constraints(scope, owner, assoc_klass, refl) + chain = refl.chain + scope_chain = refl.scope_chain + tables = construct_tables(chain, assoc_klass, refl) chain.each_with_index do |reflection, i|