1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor CollectionProxy#scope to avoid calling #extend.

This commit is contained in:
James Golick 2013-04-02 15:15:22 -07:00
parent c959798571
commit 22417c2112
2 changed files with 3 additions and 5 deletions

View file

@ -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

View file

@ -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