module Mongoid::Timestamps::Created

def able_to_set_created_at?

Returns:
  • (true, false) - If the timestamp can be set.
def able_to_set_created_at?
  !frozen? && !timeless? && !created_at
end

def set_created_at

Other tags:
    Example: Set the created at time. -
def set_created_at
  if able_to_set_created_at?
    now = Time.current
    self.updated_at = now if is_a?(Updated) && !updated_at_changed?
    self.created_at = now
  end
  clear_timeless_option
end