aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/associations/association_scope.rb17
1 files 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|