aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping/named.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-28 22:43:09 +0930
committerGitHub <noreply@github.com>2017-05-28 22:43:09 +0930
commit58a5aa40ec869839fc514116fb81a135050082f6 (patch)
tree7fb752b7a59f3264c61ba361421f9e9b498aed39 /activerecord/lib/active_record/scoping/named.rb
parentf4863ddb35260d9873cc535fdfbe82027622e8e6 (diff)
parent694900ec1611fb792d611f4260d94c0e060627a3 (diff)
downloadrails-58a5aa40ec869839fc514116fb81a135050082f6.tar.gz
rails-58a5aa40ec869839fc514116fb81a135050082f6.tar.bz2
rails-58a5aa40ec869839fc514116fb81a135050082f6.zip
Merge pull request #29197 from kamipo/enable_extending_even_if_scope_returns_nil
Enable extending even if scope returns nil
Diffstat (limited to 'activerecord/lib/active_record/scoping/named.rb')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 27cdf8cb7e..029156189d 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -156,17 +156,17 @@ module ActiveRecord
if body.respond_to?(:to_proc)
singleton_class.send(:define_method, name) do |*args|
- scope = all.scoping { instance_exec(*args, &body) }
+ scope = all
+ scope = scope.scoping { instance_exec(*args, &body) || scope }
scope = scope.extending(extension) if extension
-
- scope || all
+ scope
end
else
singleton_class.send(:define_method, name) do |*args|
- scope = all.scoping { body.call(*args) }
+ scope = all
+ scope = scope.scoping { body.call(*args) || scope }
scope = scope.extending(extension) if extension
-
- scope || all
+ scope
end
end
end