Move work for a reason
Rails Active Job provides an interface for work executed through a queue backend. It can help move tasks such as email delivery and data processing outside the immediate web request. Choose deferred work based on what the user can safely wait for, rather than moving every slow operation indiscriminately.
Give the user a truthful status
A queued export is not a completed export. Let the interface distinguish waiting, processing, completed and failed outcomes when those differences matter. Include the relevant record or request identifier so support can connect a reported problem to the work behind it.
Prepare for another execution
A job may be retried after a failure. Design its business action so another execution does not repeat an unintended side effect. Before sending an external request or writing a final result, decide how the system will recognize work that has already completed.
Carry the right context
A job runs later, when the original request context is gone. Make the required account context and identifiers explicit. Decide what should happen if a record was deleted or changed while the task waited. Recheck permissions where the product requires access to remain valid at execution time.
Operate the queue
Monitor delayed work and failed jobs as part of normal operations. Agree on when to retry automatically, when to stop and who should investigate. Test a failure halfway through the task, not only an exception before it begins. A useful job design includes the recovery path alongside the successful result.
