From 6b509dd18ca2a132342e9b850c00afc9b2a024b0 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 5 Sep 2017 06:19:23 +0900 Subject: [PATCH] Don't pass unneeded `reflection` to `add_constraints` Because `refl.scope` is the same meaning with `chain_head.scope`. --- .../lib/active_record/associations/association_scope.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index e790bd3db9..0e849c06ef 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -27,7 +27,7 @@ module ActiveRecord chain_head, chain_tail = get_chain(reflection, association, alias_tracker) scope.extending! reflection.extensions - add_constraints(scope, owner, reflection, chain_head, chain_tail) + add_constraints(scope, owner, chain_head, chain_tail) end def join_type @@ -126,7 +126,7 @@ module ActiveRecord [runtime_reflection, previous_reflection] end - def add_constraints(scope, owner, refl, chain_head, chain_tail) + def add_constraints(scope, owner, chain_head, chain_tail) owner_reflection = chain_tail table = owner_reflection.alias_name scope = last_chain_scope(scope, table, owner_reflection, owner) @@ -146,7 +146,7 @@ module ActiveRecord reflection.constraints.each do |scope_chain_item| item = eval_scope(reflection, table, scope_chain_item, owner) - if scope_chain_item == refl.scope + if scope_chain_item == chain_head.scope scope.merge! item.except(:where, :includes) end