aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-15 18:52:19 +0900
committerGitHub <noreply@github.com>2019-02-15 18:52:19 +0900
commitb414ca3f17c76fb1cc43d79fbffd2f3ed95acdde (patch)
treeb6a2e96b920725608389c972cb731f0433832b10 /activerecord/lib/active_record/scoping
parent870377915af301c98a54f7f588e077610b2190aa (diff)
parent4c6171d6056a346a953792a954853d14c000dc90 (diff)
downloadrails-b414ca3f17c76fb1cc43d79fbffd2f3ed95acdde.tar.gz
rails-b414ca3f17c76fb1cc43d79fbffd2f3ed95acdde.tar.bz2
rails-b414ca3f17c76fb1cc43d79fbffd2f3ed95acdde.zip
Merge pull request #35280 from kamipo/deprecate_leaking_scope
Deprecate using class level querying methods if the receiver scope regarded as leaked
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 5278eb29a9..681a5c6250 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -27,6 +27,14 @@ module ActiveRecord
scope = current_scope
if scope
+ if scope._deprecated_scope_source
+ ActiveSupport::Deprecation.warn(<<~MSG.squish)
+ Class level methods will no longer inherit scoping from `#{scope._deprecated_scope_source}`
+ in Rails 6.1. To continue using the scoped relation, pass it into the block directly.
+ To instead access the full set of models, as Rails 6.1 will, use `#{name}.unscoped`.
+ MSG
+ end
+
if self == scope.klass
scope.clone
else
@@ -180,7 +188,7 @@ module ActiveRecord
if body.respond_to?(:to_proc)
singleton_class.define_method(name) do |*args|
- scope = all._exec_scope(*args, &body)
+ scope = all._exec_scope(name, *args, &body)
scope = scope.extending(extension) if extension
scope
end