Complete the code to send an email asynchronously using Active Job.
UserMailer.welcome_email(user).[1]Using deliver_later queues the email to be sent in the background.
Complete the code to define a mailer method that sends a welcome email.
def welcome_email(user) @user = user mail(to: @user.email, subject: [1]) end
The subject option requires a string with quotes.
Fix the error in the Active Job class to perform email delivery.
class UserMailerJob < ApplicationJob queue_as :default def perform(user) UserMailer.welcome_email([1]).deliver_now end end
The method receives user as argument and should pass it to the mailer.
Fill both blanks to enqueue the mailer job with the user argument.
UserMailerJob.[1]([2])
perform_later enqueues the job; user is the argument passed.
Fill all three blanks to create a hash of emails and subjects for users with more than 5 posts.
emails = users.select { |user| user.posts.count [2] 5 and user.active? == [3] }.map { |user| [user.email, [1]] }.to_hUse user.name for the subject, check if posts count is greater than 5, and active status is true.
