{"issue":{"milestone":null,"title":"Use fields with default value in scope conditions for existing documents","created_at":"2011-12-30T21:18:49Z","user":{"login":"rainux","id":13707,"url":"https://api.github.com/users/rainux","avatar_url":"https://secure.gravatar.com/avatar/bd6b86d963816e225d1269857ec47049?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"bd6b86d963816e225d1269857ec47049"},"labels":[],"updated_at":"2011-12-30T21:18:49Z","state":"open","id":2691751,"closed_at":null,"html_url":"https://github.com/mongoid/mongoid/issues/1537","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"Say we have a Post model like this:\r\n\r\n```ruby\r\nclass Post\r\n  include Mongoid::Document\r\n\r\n  field :title, type: String\r\nend\r\n```\r\nAfter saved some posts, we're going to add a `public` state to `Post` model:\r\n\r\n```ruby\r\nclass Post\r\n  include Mongoid::Document\r\n\r\n  field :title, type: String\r\n  field :public, type: Boolean, default: true\r\n\r\n  scope :public, where(public: true)\r\nend\r\n```\r\n\r\nWe 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.\r\n\r\nIs it an issue or an intended behavior? How should we handle issues like this?","number":1537,"url":"https://api.github.com/repos/mongoid/mongoid/issues/1537","comments":0,"assignee":null},"action":"opened"}