在我们的rails 3.2应用程序中,我们已经配置了
config.time_zone = 'London'
config.active_record.default_timezone = :local
并且在postgresql中也配置了时区为"Europe/London"
在过去的一周中,我们的应用程序datetime字段不能正常工作。
例如,如果我们创建一个提醒start_date at 2015-08-18 10AM
。在postgres数据库中创建"2015-08-18 10:00:00"。
在模板中显示时,
提醒start date: 2015-08-18 10AM (2015-08-18 10:00:00 +0100 )
BUT,(not always) now frequently its showing UTC time.
提醒start date: 2015-08-18 9AM (2015-08-18 09:00:00 UTC )
它不能在开发中复制。
如果我们重新启动独角兽服务器,那么它将不会在4小时内发生。
有人遇到过这种问题吗?
我修复了这个问题,通过在ApplicationController
中添加around filter
。
around_filter :use_time_zone
private
def use_time_zone(&block)
Time.use_zone('London', &block)
end
因此,每当默认时区更改为UTC
时,它将覆盖并设置为BST
。