Challenge - 5 Problems
Background Email Delivery Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when you call
deliver_later on a mailer?In Rails, when you use
deliver_later on a mailer method, what is the expected behavior?Ruby on Rails
UserMailer.welcome_email(user).deliver_later
Attempts:
2 left
💡 Hint
Think about how Rails handles background jobs for emails.
✗ Incorrect
Using
deliver_later queues the email to be sent asynchronously using Active Job, so the request is not blocked.📝 Syntax
intermediate2:00remaining
Identify the correct way to enqueue a mailer with arguments
Which of the following is the correct syntax to send a welcome email asynchronously with a user argument?
Attempts:
2 left
💡 Hint
Remember the order: call mailer method first, then deliver_later.
✗ Incorrect
You call the mailer method with arguments first, then chain
deliver_later to enqueue the email.🔧 Debug
advanced3:00remaining
Why does the email never get sent when using
deliver_later?You have this code in your controller:
But no emails are sent and no errors appear. What is the most likely cause?
UserMailer.welcome_email(@user).deliver_laterBut no emails are sent and no errors appear. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check your Active Job queue adapter in the environment config.
✗ Incorrect
When the queue adapter is :test, jobs are enqueued but not run automatically, so emails are not sent.
🧠 Conceptual
advanced2:30remaining
What is the benefit of using
deliver_later over deliver_now?Why should you prefer
deliver_later instead of deliver_now in a web request?Attempts:
2 left
💡 Hint
Think about how web requests should avoid waiting on slow tasks.
✗ Incorrect
deliver_later queues the email to be sent asynchronously, so the user does not wait for the email to send.
❓ state_output
expert3:00remaining
What is the state of the job queue after calling
deliver_later once?Given this code:
Assuming the queue adapter is :async and no other jobs are running, what is the state of the job queue immediately after this call?
UserMailer.notification_email(user).deliver_laterAssuming the queue adapter is :async and no other jobs are running, what is the state of the job queue immediately after this call?
Attempts:
2 left
💡 Hint
deliver_later enqueues exactly one job for the email delivery.
✗ Incorrect
deliver_later enqueues a single job immediately to send the email asynchronously.