I am using this setup in config/environments/production.rb
:
config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = 'Eastern Time (US & Canada)'
But when I am deploying the application to the server, I am seeing these warning messages:
warning: :database_timezone option must be :utc or :local - defaulting to :local
How to fix this warning? Should I add another config.active_record.default_timezone
with :utc
?
Rails cannot use the timezone I set above?
Thank you.
From: http://guides.rubyonrails.org/configuring.html#configuring-active-record
config.time_zone
sets the default time zone for the application and enables time zone awareness for Active Record.
config.active_record.default_timezone
determines whether to use Time.local (if set to :local) or Time.utc (if set to :utc) when pulling dates and times from the database. The default is :local.
So based on this, if you want to override your default timezone to Eastern time, you'd want to do:
config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = :local
Let me know if this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.