0
0
Ruby on Railsframework~5 mins

Mailer generation and templates in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command do you use to generate a new mailer in Rails?
You use rails generate mailer MailerName to create a new mailer with default files.
Click to reveal answer
beginner
Where do Rails mailer templates live?
Mailer templates are stored in app/views/mailer_name/ folder, with one file per email action.
Click to reveal answer
intermediate
How do you define an email method inside a Rails mailer?
Inside the mailer class, define a method that sets instance variables and calls mail(to:, subject:) to send the email.
Click to reveal answer
beginner
What file extension do Rails mailer templates use for HTML emails?
Rails uses .html.erb files for HTML email templates, combining HTML with embedded Ruby.
Click to reveal answer
intermediate
How can you preview emails in Rails during development?
You can preview emails by creating a preview class in <code>test/mailers/previews</code> and visiting <code>http://localhost:3000/rails/mailers</code>.
Click to reveal answer
Which command generates a mailer named 'UserMailer' in Rails?
Arails generate mailer UserMailer
Brails generate model UserMailer
Crails generate controller UserMailer
Drails generate job UserMailer
Where do you place the email template files for a mailer called 'NotificationMailer'?
Aapp/controllers/notification_mailer/
Bapp/mailers/notification_mailer/
Capp/views/notification_mailer/
Dapp/assets/notification_mailer/
What method do you call inside a mailer method to send an email?
Asend_email()
Bmail()
Cdeliver_now()
Demail_send()
Which file extension is used for plain text email templates in Rails?
A.text.plain
B.text.erb
C.html.erb
D.txt.erb
How can you preview emails in Rails without sending them?
ABy visiting <code>/rails/mailers</code> in the browser during development
BUsing <code>rails mailer preview</code> command
CEmails cannot be previewed without sending
DUsing <code>rails email preview</code> gem only
Explain the steps to create and send an email using a Rails mailer.
Think about generating, coding the method, templates, and sending.
You got /6 concepts.
    Describe how Rails mailer templates work and where they are stored.
    Focus on folder location, file types, and how templates use Ruby.
    You got /5 concepts.