Last time we added custom editable mail templates to our mailers and made them Markdown format [read first]. Awesome. Let’s add a preview to the templates with 37-signals mail_view. I don’t know how we lived without this before!
Gemfile
Routes
Remember how we pre-declared our mailers in a hash. This is going to come in handy for config/routes.rb.
Now we have a mail_templates/devise/mailer/preview/reset_password_instructions path for a Devise::Mailer mailer!
Preview
This needs to route somewhere. Let’s add a preview into our overridden DeviseMailer.
Why Chuck Norris? I’ve been enjoying the Chuck Norris Jenkins Plugin too much lately. Chuck Norris can preview mail templates in PDF!
Here’s our mail templates admin page with a link to the preview (mail_templates/index.html.haml).
Well, that’s it. You need to add a Preview class for every mailer.