diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-04-22 09:22:43 +0200 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-04-25 15:45:05 +0100 |
commit | f3fce59d13ddf89b79d4819b3290404ba792d049 (patch) | |
tree | 8688ed89d9db6602e0cce150acd049a497f3a8f4 /activerecord/lib | |
parent | 408437334bcb5df8d8daf7b60c13d496222954d2 (diff) | |
download | rails-f3fce59d13ddf89b79d4819b3290404ba792d049.tar.gz rails-f3fce59d13ddf89b79d4819b3290404ba792d049.tar.bz2 rails-f3fce59d13ddf89b79d4819b3290404ba792d049.zip |
extract to active_record_deprecated_finders
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/scoping/default.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index c887a106ef..db833fc7f1 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -87,10 +87,10 @@ module ActiveRecord # # Should return a scope, you can call 'super' here etc. # end # end - def default_scope(scope = {}) + def default_scope(scope = nil) scope = Proc.new if block_given? - if scope.is_a?(Relation) || !scope.is_a?(Hash) && !scope.respond_to?(:call) + if scope.is_a?(Relation) || !scope.respond_to?(:call) ActiveSupport::Deprecation.warn( "Calling #default_scope without a block is deprecated. For example instead " \ "of `default_scope where(color: 'red')`, please use " \ @@ -103,14 +103,13 @@ module ActiveRecord end def build_default_scope #:nodoc: - if method(:default_scope).owner != ActiveRecord::Scoping::Default::ClassMethods + if !Base.is_a?(method(:default_scope).owner) + # The user has defined their own default scope method, so call that evaluate_default_scope { default_scope } elsif default_scopes.any? evaluate_default_scope do default_scopes.inject(relation) do |default_scope, scope| - if scope.is_a?(Hash) - default_scope.apply_finder_options(scope) - elsif !scope.is_a?(Relation) && scope.respond_to?(:call) + if !scope.is_a?(Relation) && scope.respond_to?(:call) default_scope.merge(unscoped { scope.call }) else default_scope.merge(scope) |