mongoid/mongoid — Issue #1537: Use fields with default value in scope conditions for existing documents
Author: rainux
Created: 2011-12-30 21:18:49+00:00
State: open

Say we have a Post model like this:

```ruby
class Post
include Mongoid::Document

field :title, type: String
end
```
After saved some posts, we're going to add a `public` state to `Post` model:

```ruby
class Post
include Mongoid::Document

field :title, type: String
field :public, type: Boolean, default: true

scope :public, where(public: true)
end
```

We want all existing posts default to public state, that's works well for single `post` object, however, `Post.public` can't retrieve those existing posts, because they don't really have a `:public` field.

Is it an issue or an intended behavior? How should we handle issues like this?