aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-07-19 07:52:53 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-07-19 18:55:29 +0900
commit1173c7cad3684048c53f2ef9a5c936d9e58e75d0 (patch)
treea4f1c125a8cb84b98e45f2d2d1711ce81731e813 /activerecord/lib
parent9fc728cf09adf318bf58c59b7f4ca41f57a6f6b1 (diff)
downloadrails-1173c7cad3684048c53f2ef9a5c936d9e58e75d0.tar.gz
rails-1173c7cad3684048c53f2ef9a5c936d9e58e75d0.tar.bz2
rails-1173c7cad3684048c53f2ef9a5c936d9e58e75d0.zip
Avoid extra scoping in delegating to klass methods in the `scope` block
Since #29301, delegating to klass methods in the `scope` block would cause extra scoping by the receiver itself. The extra scoping would always override intermediate scoping like `unscoped` and caused the regression #33387. To keep the original scoping behavior, should avoid the extra scoping in the `scope` block. Fixes #33387.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 7ab9bb2d2d..fce5b66719 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -309,10 +309,10 @@ module ActiveRecord
# Please check unscoped if you want to remove all previous scopes (including
# the default_scope) during the execution of a block.
def scoping
- previous, klass.current_scope = klass.current_scope(true), self
+ previous, klass.current_scope = klass.current_scope(true), self unless @delegate_to_klass
yield
ensure
- klass.current_scope = previous
+ klass.current_scope = previous unless @delegate_to_klass
end
def _exec_scope(*args, &block) # :nodoc: