diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-05-24 06:25:09 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-05-24 06:39:20 +0900 |
commit | 694900ec1611fb792d611f4260d94c0e060627a3 (patch) | |
tree | 4734586f404756016f0f13e31ebaa32d24d7c63a /activerecord/lib/active_record | |
parent | 845aabbcd3805420090f8b92b50a4562577cf210 (diff) | |
download | rails-694900ec1611fb792d611f4260d94c0e060627a3.tar.gz rails-694900ec1611fb792d611f4260d94c0e060627a3.tar.bz2 rails-694900ec1611fb792d611f4260d94c0e060627a3.zip |
Enable extending even if scope returns nil
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/scoping/named.rb | 12 |
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 |