aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-02-13 15:58:28 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-02-14 11:15:54 -0800
commita8775bba58fb9dd3b0a51a812fa6ec43d8084ff6 (patch)
treed6bb04c6dd7420f9d7228e455736c544c3f7a8c4
parent279212d8b12e03a17fd45a33c74f37f8ac844650 (diff)
downloadrails-a8775bba58fb9dd3b0a51a812fa6ec43d8084ff6.tar.gz
rails-a8775bba58fb9dd3b0a51a812fa6ec43d8084ff6.tar.bz2
rails-a8775bba58fb9dd3b0a51a812fa6ec43d8084ff6.zip
remove chain delegate
-rw-r--r--activerecord/lib/active_record/associations/association_scope.rb11
1 files 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