Posted about 6 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.

Integration to RSpec

All you need to do is implement a preview-class in spec/mailers/previews/notifier_preview.rb:

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

And change adjust the preview load path in your application.rb:

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

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 .

Rails <4.1

You could use Mailcatcher.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Judith Roth
Last edit:
7 days 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 short-lived cookies to improve usability.
Accept or learn more