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:
parent
c959798571
commit
22417c2112
2 changed files with 3 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue