aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-04-05 05:37:17 -0700
committerJon Leighton <j@jonathanleighton.com>2013-04-05 05:37:17 -0700
commitbab0e2804d1c061bf639e2fb01ffc27b9e98384e (patch)
tree36ccfb9d6ccedf55b98d37f1b8c7dc90e75fd200 /activerecord
parent8606a7fbe9367e9ae37ad058dd07f0dd38daf015 (diff)
parent22417c2112336b14a21a91819537bd951c15ee60 (diff)
downloadrails-bab0e2804d1c061bf639e2fb01ffc27b9e98384e.tar.gz
rails-bab0e2804d1c061bf639e2fb01ffc27b9e98384e.tar.bz2
rails-bab0e2804d1c061bf639e2fb01ffc27b9e98384e.zip
Merge pull request #10058 from jamesgolick/master
Avoid calling define_method in CollectionProxy#scope
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb6
-rw-r--r--activerecord/lib/active_record/relation.rb2
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 83b7aecd54..8a5b312862 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -847,10 +847,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