lib/mongoid/persistence.rb
# Touch the document, in effect updating it's updated_at timestamp and
# optionally the provided field to the current time. If any belongs_to
# relations exist with a touch option, they will be updated as well.
#
# @example Update the updated_at timestamp.
#   document.touch
#
# @example Update the updated_at and provided timestamps.
#   document.touch(:audited)
#
# @note This will not autobuild relations if those options are set.
#
# @param [ Symbol ] field The name of an additional field to update.
#
# @return [ true ] true.
#
# @since 3.0.0
Touch the document, in effect updating it's updated_at timestamp and
optionally the provided field to the current time. If any belongs_to
relations exist with a touch option, they will be updated as well.
Touch the document in effect updating it ' s updated_at timestamp and optionally the provided field to the current time . If any belongs_to relations exist with a touch option they will be updated as well .
def touch(field = nil)
      current = Time.now
      write_attribute(:updated_at, current) if fields["updated_at"]
      write_attribute(field, current) if field
      _root.collection.find(atomic_selector).update(atomic_updates)
      without_autobuild do
        touchables.each { |name| send(name).try(:touch) }
      end
      move_changes and true
    end
def touch ( field = nil ) current = Time . now write_attribute ( :updated_at , current ) if fields [ "updated_at" ] write_attribute ( field , current ) if field _root . collection . find ( atomic_selector ) . update ( atomic_updates ) without_autobuild do touchables . each { | name | send ( name ) . try ( :touch ) } end move_changes and true end
Touch the document, in effect updating it's updated_at timestamp and
optionally the provided field to the current time.
Touch the document in effect updating it ' s updated_at timestamp and optionally the provided field to the current time .
None
 true 
field
<not_specific>
<not_specific>
field The name of an additional field to update.
field The name of an additional field to update .
example
Update the updated_at timestamp. document.touch
Update the updated_at timestamp . document . touch
example
Update the updated_at and provided timestamps. document.touch(:audited)
Update the updated_at and provided timestamps . document . touch ( : audited )
note
This will not autobuild relations if those options are set.
This will not autobuild relations if those options are set .
since
None