Complete the code to define a mailer preview class in Rails.
class UserMailerPreview < [1] end
Mailer preview classes in Rails inherit from ActionMailer::Preview to enable previewing emails.
Complete the method to preview the welcome email for a user.
def welcome_email UserMailer.[1](User.first) end
The mailer method to preview is usually named after the email, here welcome_email.
Fix the error in this preview method to correctly return the mail object.
def notification_email mail = UserMailer.notification_email(User.last) [1] mail end
Preview methods must return the mail object, so return mail is correct.
Fill both blanks to define a preview method that previews an email with a sample user and a token.
def reset_password_email user = User.find_by(email: [1]) UserMailer.reset_password_email(user, [2]) end
Use a sample email string and a sample token string to preview the reset password email.
Fill all three blanks to create a preview method that sends a newsletter email to a user with a subject.
def newsletter_email user = User.find_by(email: [1]) subject = [2] UserMailer.newsletter_email(user, subject: [3]) end
Use a sample email string for the user, assign a subject string, and pass the subject variable to the mailer.