Why is the timezone off in delayed_job?

前端 未结 1 1399
野的像风
野的像风 2021-01-18 23:55

In my Rails app, when I create a background job using the delayed_job gem, I get all times offset by 6 hours.

My understanding is that delayed_job uses your timezone

相关标签:
1条回答
  • 2021-01-19 00:41

    The problem was in my config/application.rb as @rainkinz suggested, specifically the 2nd line:

    config.time_zone = 'Central Time (US & Canada)'
    config.active_record.default_timezone = 'Central Time (US & Canada)'
    

    Apparently the default_timezone setting is deprecated after Rails 3.2.13, which I just upgraded from a few days ago.

    When I changed it to only have the local time zone set:

    config.time_zone = 'Central Time (US & Canada)'
    #config.active_record.default_timezone = 'Central Time (US & Canada)'
    

    This fixed the problem. All active record objects still seem to have the correct time when saved, as do delayed_jobs.

    0 讨论(0)
提交回复
热议问题