Rails 6 now preserves timezones for Active Job.
It records what was the current timezone in effect
when the job was enqueued
and then restores when the job is executed.
When using an application in different timezones,
it can get tricky to handle timezones,
on Rails Request level, passing to background jobs and more.
In one of our applications,
we allow users to create tasks that can be
assigned a due at date.
This date can take
“today”, “tomorrow”, etc relative date values,
which are also relative
to the timezone
the user is accessing the Application in.
We process this task creation in a background job
as it has some extra work
that it needs to take care of after creating the task.
After changes in Rails 6 for ActiveJob,
passing timezone to Job,
is taken care of, by Rails itself.
Propagation to children
This kind of timezone propagation is also useful,
when calling Jobs in a nested fashion.
We don’t need to make sure or take care of,
passing the timezone
to all subsequent nested Jobs.
More useful ENV settings from Active Job
Apart from timezone, Rails already supported
propagating the current locale
when the Job is Enqueued