Recall & Review
beginner
What is the purpose of the Active Job framework in Rails?
Active Job provides a simple way to declare jobs and run them on various queueing backends. It helps you run tasks in the background, like sending emails or processing data, without blocking the main app.
Click to reveal answer
beginner
How do you create a new job using Active Job?
You create a new job by running
rails generate job JobName. This creates a job file where you define the perform method with the task you want to run in the background.Click to reveal answer
beginner
What method do you call to run a job asynchronously in Active Job?
You call <code>perform_later</code> on the job class to enqueue the job to run in the background. For example, <code>MyJob.perform_later(args)</code>.Click to reveal answer
intermediate
Name two queue adapters supported by Active Job.
Active Job supports many adapters like Sidekiq, Resque, Delayed Job, and the default Async adapter.
Click to reveal answer
intermediate
Why is Active Job useful when switching queue backends?
Active Job provides a unified interface for jobs. This means you can switch queue backends (like from Sidekiq to Resque) without changing your job code, making your app flexible and easier to maintain.
Click to reveal answer
Which method enqueues a job to run later in Active Job?
✗ Incorrect
The
perform_later method enqueues the job to run asynchronously in the background.What file is generated when you run
rails generate job JobName?✗ Incorrect
Generating a job creates a job file where you define the
perform method for background tasks.Which of these is NOT a queue adapter supported by Active Job?
✗ Incorrect
Puma is a web server, not a queue adapter. Sidekiq, Resque, and Delayed Job are queue adapters.
What is the default queue adapter in Active Job if none is specified?
✗ Incorrect
The default adapter is Async, which runs jobs in separate threads within the Rails process.
Why use Active Job instead of directly using a queue adapter?
✗ Incorrect
Active Job abstracts queue adapters, so you can switch them without changing your job code.
Explain how Active Job helps manage background tasks in a Rails app.
Think about how you would send emails or process data without slowing down the app.
You got /4 concepts.
Describe the steps to create and run a background job using Active Job.
Start from creating the job file to making it run in the background.
You got /4 concepts.