Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor CollectionProxy#scope to avoid calling #extend.

  • Loading branch information...
commit 22417c2112336b14a21a91819537bd951c15ee60 1 parent c959798
@jamesgolick jamesgolick authored
View
6 activerecord/lib/active_record/associations/collection_proxy.rb
@@ -848,10 +848,8 @@ def scoping
# 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
View
2  activerecord/lib/active_record/relation.rb
@@ -17,7 +17,7 @@ class Relation
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
Please sign in to comment.
Something went wrong with that request. Please try again.