Sha256: 6b2cad65900889a93d39b254b93eda5139633e795cec23fd3f1890ea35c2a717
Contents?: true
Size: 688 Bytes
Versions: 8
Compression:
Stored size: 688 Bytes
Contents
# encoding: utf-8 module Mongoid module Timestamps extend ActiveSupport::Concern included do field :created_at, :type => Time field :updated_at, :type => Time before_save :set_created_at, :set_updated_at end module InstanceMethods # Update the created_at field on the Document to the current time. This is # only called on create. def set_created_at self.created_at = Time.now.utc if !created_at end # Update the updated_at field on the Document to the current time. # This is only called on create and on save. def set_updated_at self.updated_at = Time.now.utc end end end end
Version data entries
8 entries across 8 versions & 4 rubygems