lib/mongoid/fields.rb in mongoid-2.4.7 vs lib/mongoid/fields.rb in mongoid-2.4.8
- old
+ new
@@ -90,11 +90,13 @@
# @since 2.4.0
def apply_default(name)
unless attributes.has_key?(name)
if field = fields[name]
default = field.eval_default(self)
- attribute_will_change!(name)
- attributes[name] = default
+ unless default.nil?
+ attribute_will_change!(name)
+ attributes[name] = default
+ end
end
end
end
# Apply all the defaults at once.