diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-23 13:40:38 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-23 13:41:09 +0530 |
commit | 8ff2fb6f3aa6140f5a8bd018d5919a8a1e707cda (patch) | |
tree | ddffd8e35044c3c56336819d585e0896b1d3b457 /activerecord/lib/active_record | |
parent | c2e57c0bb02396cd7762d67f5dd8d6aa1e1814a9 (diff) | |
download | rails-8ff2fb6f3aa6140f5a8bd018d5919a8a1e707cda.tar.gz rails-8ff2fb6f3aa6140f5a8bd018d5919a8a1e707cda.tar.bz2 rails-8ff2fb6f3aa6140f5a8bd018d5919a8a1e707cda.zip |
Make default_scope work with Relations
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f1b2b3b979..12feef4849 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1236,7 +1236,7 @@ module ActiveRecord #:nodoc: end def construct_finder_arel(options = {}, scope = nil) - relation = unscoped.apply_finder_options(options) + relation = options.is_a?(Hash) ? unscoped.apply_finder_options(options) : unscoped.merge(options) relation = scope.merge(relation) if scope relation end @@ -1450,7 +1450,8 @@ module ActiveRecord #:nodoc: end def scoped_methods #:nodoc: - Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup + key = :"#{self}_scoped_methods" + Thread.current[key] = Thread.current[key].presence || self.default_scoping.dup end def current_scoped_methods #:nodoc: |