mongoid/mongoid — Issue #1764: Default attributes considered as dirty
Author: alexistoulotte
Created: 2012-02-27 04:26:23+00:00
State: open

Hello,

Mongoid has a strange behavior with default field value and dirty. Active Record does not have same behavior.

class Article
include Mongoid::Document
field :body, :type => String, :default => ''
end

Article.new.changed?
=> true
Article.new.body
=> ''
Article.new.body_was
=> nil

In A/R :

Article.new.changed?
=> false
Article.new.body
=> ''
Article.new.body_was
=> ''