lib/mongoid/touchable.rb in mongoid-8.1.5 vs lib/mongoid/touchable.rb in mongoid-8.1.6
- old
+ new
@@ -23,10 +23,10 @@
def touch(field = nil)
return false if _root.new_record?
current = Time.configured.now
field = database_field_name(field)
write_attribute(:updated_at, current) if respond_to?("updated_at=")
- write_attribute(field, current) if field
+ write_attribute(field, current) if field.present?
# If the document being touched is embedded, touch its parents
# all the way through the composition hierarchy to the root object,
# because when an embedded document is changed the write is actually
# performed by the composition root. See MONGOID-3468.