This blog is part of our Rails 6 series.
Rails 6.0 was recently released.
When a job is enqueued in
using Active Job, the current timezone of a job is
and then this preserved timezone is restored when the job is finished executing.
Let’s take an example of sale at Amazon.
Amazon would like to remind users across different timezones about its upcoming sale by sending an email.
This task of sending a reminder would be processed as a background job.
Before Rails 6, we had to pass timezone explicitly to the
perform method of the job as shown below.
After the changes in Rails 6, passing timezone to Job is now taken care of by Rails.
Rails 6 also propagates timezone to all the subsequent nested jobs.