diff options
author | James Golick <jamesgolick@gmail.com> | 2013-04-02 15:15:22 -0700 |
---|---|---|
committer | James Golick <jamesgolick@gmail.com> | 2013-04-02 15:16:04 -0700 |
commit | 22417c2112336b14a21a91819537bd951c15ee60 (patch) | |
tree | 20f522c18a74c8bce8288a30e850c911811bcc9a /activerecord | |
parent | c959798571b4060b19712e022f4236d75b2b7cfd (diff) | |
download | rails-22417c2112336b14a21a91819537bd951c15ee60.tar.gz rails-22417c2112336b14a21a91819537bd951c15ee60.tar.bz2 rails-22417c2112336b14a21a91819537bd951c15ee60.zip |
Refactor CollectionProxy#scope to avoid calling #extend.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index c2add32aa6..c01ec36179 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -848,10 +848,8 @@ module ActiveRecord # Returns a <tt>Relation</tt> object for the records in this association def scope - association = @association - - @association.scope.extending! do - define_method(:proxy_association) { association } + @association.scope.tap do |scope| + scope.proxy_association = @association end end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index c7b6c715f5..56462d355b 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -17,7 +17,7 @@ module ActiveRecord include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation attr_reader :table, :klass, :loaded - attr_accessor :default_scoped + attr_accessor :default_scoped, :proxy_association alias :model :klass alias :loaded? :loaded alias :default_scoped? :default_scoped |