Sha256: 06e4aa31497b5400901e0d70d7bd5ccf85d19153ac367e7aa0fe6a08f8f5af75
Contents?: true
Size: 784 Bytes
Versions: 4
Compression:
Stored size: 784 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Timestamps # This module handles the behaviour for setting up document updated at # timestamp. module Updated extend ActiveSupport::Concern included do field :updated_at, :type => Time, :versioned => false set_callback :save, :before, :set_updated_at, :if => Proc.new { |doc| doc.timestamping? && (doc.new_record? || doc.changed?) } end # Update the updated_at field on the Document to the current time. # This is only called on create and on save. # # @example Set the updated at time. # person.set_updated_at def set_updated_at self.updated_at = Time.now.utc unless self.updated_at_changed? end end end end
Version data entries
4 entries across 4 versions & 1 rubygems