#171 Delayed Job (revised)
Long requests should be moved into a background process, and Delayed Job is one of the easiest ways to do this because it works with an Active Record database.
- source codeProject Files in Zip (84.4 KB)
- mp4Full Size H.264 Video (23.2 MB)
- m4vSmaller H.264 Video (10.5 MB)
- webmFull Size VP8 Video (10.6 MB)
- ogvFull Size Theora Video (25.6 MB)
Note: What I stated in the episode about job priority is incorrect. A priority of "0" is top priority and will be processed before a priority of 10 or some higher number.
rails g delayed_job:active_record
Newsletter.delay(queue: "newsletter", priority: 20, run_at: 5.minutes.from_now).deliver(params[:id])
Delayed::Worker.max_attempts = 5
Delayed::Worker.delay_jobs = !Rails.env.test?