From a8775bba58fb9dd3b0a51a812fa6ec43d8084ff6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 13 Feb 2014 15:58:28 -0800 Subject: remove chain delegate --- .../lib/active_record/associations/association_scope.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index f936bcb80e..a6e453a3f1 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -4,7 +4,6 @@ module ActiveRecord attr_reader :association, :alias_tracker delegate :klass, :reflection, :to => :association - delegate :chain, :to => :reflection def initialize(association) @association = association @@ -16,7 +15,9 @@ module ActiveRecord scope.extending! Array(reflection.options[:extend]) owner = association.owner - add_constraints(scope, owner, reflection.scope_chain) + scope_chain = reflection.scope_chain + chain = reflection.chain + add_constraints(scope, owner, scope_chain, chain) end def join_type @@ -25,7 +26,7 @@ module ActiveRecord private - def construct_tables + def construct_tables(chain) chain.map do |reflection| alias_tracker.aliased_table_for( table_name_for(reflection), @@ -61,8 +62,8 @@ module ActiveRecord bind_value scope, column, value end - def add_constraints(scope, owner, scope_chain) - tables = construct_tables + def add_constraints(scope, owner, scope_chain, chain) + tables = construct_tables(chain) chain.each_with_index do |reflection, i| table, foreign_table = tables.shift, tables.first -- cgit v1.2.3