Sha256: 2849089fcb71920a706f2bab39179b10c4a0cda0ffc0d2261bec3e3e4f23d037
Contents?: true
Size: 860 Bytes
Versions: 5
Compression:
Stored size: 860 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 set_callback :save, :before, :set_updated_at, :if => Proc.new { |doc| doc.new_record? || doc.changed? } unless methods.include? 'record_timestamps' class_attribute :record_timestamps self.record_timestamps = true end 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 end end end end
Version data entries
5 entries across 5 versions & 2 rubygems