Do not use
Time.now
without zone. Use one of Time.zone.now
, Time.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.xmlschema
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.httpdate
, Time.now.to_i
, Time.now.to_f
instead. 1class User < ApplicationRecord
2 attribute :confirmed_at, :datetime, default: Time.now 3
4 after_commit :schedule_welcome_email, on: :create
5
Description
Time methods should not be used without timezone.
Bad practice
Time.now
Recommended
Time.zone.now
By default, this issue is raised when using in_time_zone
. To stop raising issues on its usage, the EnforcedStyle
configuration in .rubocop.yml
should be set to flexible
.