Module: Mongoid::Timestamps::Created
- Extended by:
- ActiveSupport::Concern
- Included in:
- Mongoid::Timestamps
- Defined in:
- lib/mongoid/timestamps/created.rb,
lib/mongoid/timestamps/created/short.rb
Overview
This module handles the behaviour for setting up document created at timestamp.
Defined Under Namespace
Modules: Short
Instance Method Summary collapse
-
#set_created_at ⇒ Object
Update the created_at field on the Document to the current time.
Instance Method Details
#set_created_at ⇒ Object
Update the created_at field on the Document to the current time. This is only called on create.
21 22 23 24 25 26 27 |
# File 'lib/mongoid/timestamps/created.rb', line 21 def set_created_at if !created_at time = Time.now.utc self.updated_at = time if is_a?(Updated) && !updated_at_changed? self.created_at = time end end |