Module: Mongoid::Timestamps::Created

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Timestamps
Defined in:
build/mongoid-master/lib/mongoid/timestamps/created.rb,
build/mongoid-master/lib/mongoid/timestamps/created/short.rb

Overview

This module handles the behavior for setting up document created at timestamp.

Defined Under Namespace

Modules: Short

Instance Method Summary collapse

Instance Method Details

#set_created_atObject

Update the created_at field on the Document to the current time. This is only called on create.

Examples:

Set the created at time.

person.set_created_at


25
26
27
28
29
30
31
32
# File 'build/mongoid-master/lib/mongoid/timestamps/created.rb', line 25

def set_created_at
  if !timeless? && !created_at
    time = Time.now.utc
    self.updated_at = time if is_a?(Updated) && !updated_at_changed?
    self.created_at = time
  end
  clear_timeless_option
end