Complete the code to define a basic Active Job class.
class MyJob < ApplicationJob queue_as :[1] def perform(*args) # job code here end end
The queue_as method sets the queue name. default is the standard queue name in Rails Active Job.
Complete the code to enqueue a job to run asynchronously.
MyJob.[1](user_id)perform_now which runs the job immediatelyrun_asyncperform_later enqueues the job to run asynchronously in the background.
Fix the error in the job class to correctly access the argument.
class NotifyUserJob < ApplicationJob def perform([1]) UserMailer.welcome_email([1]).deliver_now end end
args without unpackinguser when only the ID is passedThe job receives user_id as an argument, which is passed to the mailer.
Fill both blanks to schedule a job to run 5 minutes from now.
MyJob.[1](wait: [2].minutes).perform_later
perform_later without set for schedulingset(wait: 5.minutes) schedules the job to run after 5 minutes.
Fill all three blanks to create a job that retries 3 times with 10 seconds delay between attempts.
class RetryJob < ApplicationJob [1] StandardError, wait: [2], attempts: [3] def perform # job code end end
rescue_from which handles exceptions differentlyretry_on sets retry behavior with wait time and attempts count.
