aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/collection_proxy.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-12-08 19:58:59 +0000
committerJon Leighton <j@jonathanleighton.com>2011-12-08 20:10:04 +0000
commit5da90b34831a0f941b36edbede9089c54432ad6b (patch)
tree6296bb6f42860b55bc229d88e760de8c7655d9d6 /activerecord/lib/active_record/associations/collection_proxy.rb
parentebd71fd0e39abf495bdf64e3e6d278340c17e5ea (diff)
downloadrails-5da90b34831a0f941b36edbede9089c54432ad6b.tar.gz
rails-5da90b34831a0f941b36edbede9089c54432ad6b.tar.bz2
rails-5da90b34831a0f941b36edbede9089c54432ad6b.zip
Fix #3890. (Calling proxy_association in scope chain.)
Diffstat (limited to 'activerecord/lib/active_record/associations/collection_proxy.rb')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 80bc4990d2..eb320bc774 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -41,8 +41,7 @@ module ActiveRecord
delegate :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from,
:lock, :readonly, :having, :pluck, :to => :scoped
- delegate :target, :load_target, :loaded?, :scoped,
- :to => :@association
+ delegate :target, :load_target, :loaded?, :to => :@association
delegate :select, :find, :first, :last,
:build, :create, :create!,
@@ -62,6 +61,13 @@ module ActiveRecord
@association
end
+ def scoped
+ association = @association
+ association.scoped.extending do
+ define_method(:proxy_association) { association }
+ end
+ end
+
def respond_to?(name, include_private = false)
super ||
(load_target && target.respond_to?(name, include_private)) ||