Sha256: 279a4798ab54106cd0072cb9869a8bfbba99ad1d60f2e0928727f2be91b65f78
Contents?: true
Size: 768 Bytes
Versions: 11
Compression:
Stored size: 768 Bytes
Contents
module Mongoid module Timestamps def self.included(base) base.class_eval do include InstanceMethods field :created_at, :type => Time field :modified_at, :type => Time before_create :update_created_at, :update_modified_at before_save :update_modified_at end end module InstanceMethods # Update the created_at field on the Document to the current time. This is # only called on create. def update_created_at self.created_at = Time.now.utc end # Update the last_modified field on the Document to the current time. # This is only called on create and on save. def update_modified_at self.modified_at = Time.now.utc end end end end
Version data entries
11 entries across 11 versions & 1 rubygems