aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-11-30 05:50:40 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-11-30 05:50:40 +0900
commit3090b358482942b944e5944c4869d2bf1afdefb8 (patch)
treeb170f458df19dd30343cfa6d07e1beca5c4f7fd7 /activerecord/lib/active_record
parente4aec40578ea0dd2944f97f1ad60cfbdf4b3a44d (diff)
downloadrails-3090b358482942b944e5944c4869d2bf1afdefb8.tar.gz
rails-3090b358482942b944e5944c4869d2bf1afdefb8.tar.bz2
rails-3090b358482942b944e5944c4869d2bf1afdefb8.zip
Fix the scoping with query methods in the scope block
Follow up #33394. #33394 only fixes the case of scoping with klass methods in the scope block which invokes `klass.all`. Query methods in the scope block also need to invoke `klass.all` to be affected by the scoping.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 562e04194c..7874c4c35a 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -8,7 +8,7 @@ module ActiveRecord
module SpawnMethods
# This is overridden by Associations::CollectionProxy
def spawn #:nodoc:
- clone
+ @delegate_to_klass ? klass.all : clone
end
# Merges in the conditions from <tt>other</tt>, if <tt>other</tt> is an ActiveRecord::Relation.