mongoid/mongoid — pull request #2304 by netoneko (2012-08-20 09:32:42+00:00)
Title: Merge of default_scope instead of overwrite

Today I've encountered a certain problem with `default_scope`.

If you for example define a class

```ruby
class Post
include Mongoid::Document
include Mongoid::Timestamps

field :title, type: String
field :text, type: String

default_scope desc(:title).desc(:created_at)
end
```

Maybe you want to apply ```desc(:created_at)``` to more entities you have. Why not to create a module that provides that functionality?

```ruby
module FancyTimestamps
extend ActiveSupport::Concern

self.included do
include Mongoid::Timestamps

default_scope desc(:created_at)
end
end
```

Then you can ```include FancyTimestamps``` into your entities, but then ```default_scope``` (if you provide one inside the entity) will overwrite ```default_scope``` defined inside ```FancyTimestamps```.

That's the main reason behind this patch.