-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
So, if we have document:
class Person include Mongoid::Document field :name field :surname, default: 'Smith' field :age, type: Integer end
Then
Person.create name: 'James', surname: 'Bond', age: 45 man_without_name = Person.only(:age).first man_without_name.age #=> 45 man_without_name.name #=> nil man_without_name.surname #=> 'Smith'
I think all fields with default value in this case should return nil, as for fields without default value.