diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-14 14:20:07 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-14 14:20:07 -0800 |
commit | 8e6ef92fd9ede38aa435afeaef6370ff65191a0b (patch) | |
tree | 03dc053a579d5401a12498e9ea0716881b08bb0c /activerecord/lib/active_record | |
parent | 3b675f05ffb11cdbfd3f7d416906ff16941e8367 (diff) | |
download | rails-8e6ef92fd9ede38aa435afeaef6370ff65191a0b.tar.gz rails-8e6ef92fd9ede38aa435afeaef6370ff65191a0b.tar.bz2 rails-8e6ef92fd9ede38aa435afeaef6370ff65191a0b.zip |
pass the association and connection to the scope method
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 10 |
2 files changed, 3 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 67ea489b22..2dba33898c 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -94,7 +94,7 @@ module ActiveRecord # actually gets built. def association_scope if klass - @association_scope ||= AssociationScope.new(self).scope + @association_scope ||= AssociationScope.new.scope(self, klass.connection) end end diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 1f094d42b3..cd2911e0a4 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -1,18 +1,12 @@ module ActiveRecord module Associations class AssociationScope #:nodoc: - attr_reader :association - - def initialize(association) - @association = association - end - - def scope + def scope(association, connection) klass = association.klass reflection = association.reflection scope = klass.unscoped owner = association.owner - alias_tracker = AliasTracker.new klass.connection + alias_tracker = AliasTracker.new connection scope.extending! Array(reflection.options[:extend]) add_constraints(scope, owner, klass, reflection, alias_tracker) |