Calling 'default_scope' multiple times in a class (including when a superclass calls 'default_scope') is deprecated. The current behavior is that this will merge the default scopes together:
class Post < ActiveRecord::Base # Rails 3.1
default_scope where(:published => true)
default_scope where(:hidden => false)
# The default scope is now: where(:published => true, :hidden => false)
end
In Rails 3.2, the behavior will be changed to overwrite previous scopes:
class Post < ActiveRecord::Base # Rails 3.2
default_scope where(:published => true)
default_scope where(:hidden => false)
# The default scope is now: where(:hidden => false)
end
If you wish to merge default scopes in special ways, it is recommended to define your default scope as a class method and use the standard techniques for sharing code (inheritance, mixins, etc.):