Posted over 4 years ago. Visible to the public. Repeats. Linked content.

Action Mailer Previews (since Rails 4.1)

Since Rails 4.1 there is a preview-function to see what an e-mail will look like.

All you need to do is implement a preview-class in spec/mailers/previews (if you are using RSpec):

class NotifierPreview < ActionMailer::Preview def welcome Notifier.welcome(User.first) end end

and then a preview will be available in the browser at http://localhost:3000/rails/mailers/notifier/welcome as well as a list of previews at http://localhost:3000/rails/mailers .

Note: If your preview model is not loaded you might need to change your application.rb:

config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"

Rails <4.1

You could use Mailcatcher.

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Judith Roth
Last edit:
11 months ago
by Emanuel De
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more