0
0
Ruby on Railsframework~10 mins

Scheduled jobs in Ruby on Rails - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a basic Active Job class in Rails.

Ruby on Rails
class MyJob < ApplicationJob
  queue_as :default

  def [1]
    puts "Job is running"
  end
end
Drag options to blanks, or click blank then click option'
Aperform
Brun
Cexecute
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names like 'run' or 'execute' which Rails does not recognize automatically.
2fill in blank
medium

Complete the code to enqueue a job to run asynchronously.

Ruby on Rails
MyJob.[1]
Drag options to blanks, or click blank then click option'
Arun_later
Benqueue_now
Cperform_later
Dstart_async
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'run_later' or 'start_async'.
3fill in blank
hard

Fix the error in scheduling a job to run 5 minutes from now.

Ruby on Rails
MyJob.[1](wait: 5.minutes)
Drag options to blanks, or click blank then click option'
Aperform_later
Bperform_now
Cperform_in
Dperform_at
Attempts:
3 left
💡 Hint
Common Mistakes
Using perform_now which runs the job immediately without delay.
4fill in blank
hard

Fill both blanks to create a scheduled job that runs at a specific time.

Ruby on Rails
MyJob.[1](wait_until: [2])
Drag options to blanks, or click blank then click option'
Aperform_later
Bperform_now
CTime.current + 1.hour
DTime.now
Attempts:
3 left
💡 Hint
Common Mistakes
Using perform_now which does not support scheduling.
Using Time.now which is less preferred than Time.current in Rails.
5fill in blank
hard

Fill all three blanks to define a job class with a custom queue and perform method.

Ruby on Rails
class CustomJob < ApplicationJob
  queue_as [1]

  def [2]
    puts [3]
  end
end
Drag options to blanks, or click blank then click option'
A:mailers
Bperform
C"Running CustomJob"
D:default
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect queue names or method names.
Forgetting to quote the string to print.