如何设置mysql2 timezone选项以删除查询警告

时间:2010-12-24 01:53:38

标签: ruby mysql2

当使用mysql2进行查询时,我总是会收到警告

/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

我确实看到了Timezones的选项

Mysql2现在支持两个时区选项:

  :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

有没有人知道,如何使用,以及在哪里设置此选项?

感谢。

1 个答案:

答案 0 :(得分:16)

这就是我修复它的方法:

config.active_record.default_timezone = :utc