Complete the code to enqueue a job to run asynchronously.
MyJob.perform_later([1])Use perform_later with the job argument to enqueue it asynchronously.
Complete the code to define a job class inheriting from ActiveJob.
class MyJob < [1] def perform(user_id) # job code here end end
Jobs inherit from ActiveJob::Base to get job functionality.
Fix the error in the job perform method to accept multiple arguments.
def perform([1]) # code using user_id and message end
Use *args to accept multiple arguments in the perform method.
Fill both blanks to schedule a job to run 5 minutes from now.
MyJob.set(wait: [1]).perform_later([2])
Use set(wait: 5.minutes) to delay the job, and pass the correct argument.
Fill all three blanks to retry a job on failure with a maximum of 3 attempts and 5 seconds wait between retries.
class RetryJob < ActiveJob::Base retry_on [1], wait: [2], attempts: [3] def perform # job code end end
Use retry_on RuntimeError with wait and attempts options to retry the job.
