How to set mysql2 timezone parameter to remove query alert

I always get a warning when using mysql2 do query

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:463: warning: :database_timezone option must be :utc or :local - defaulting to :local 

I saw an option for time zones

Mysql2 now supports two time zone options:

  :database_timezone - this is the timezone Mysql2 will assume fields are already stored as, and will use this when creating the initial Time objects in ruby :application_timezone - this is the timezone Mysql2 will convert to before finally handing back to the caller 

Did anyone know how to use and where to set this parameter?

Thanks.

+6
ruby mysql2
source share
1 answer

Here is how I fixed it:

 config.active_record.default_timezone = :utc 
+16
source share

All Articles