I'm having a weird issue with my TransactionMailer Preview.
I have the file test/mailers/previews/transaction_mailer_preview.rb
looking good.
When i access http://localhost:3000/rails/mailers/
i can see the TransactionMailer preview and all of its actions and the mailer preview is rendered correctly.
However, as soon as i refresh, the mailer disappears from the list and the action cannot be found. The issue is fixed if i restart the server, but only for one time, then disappears again!
Any idea? Rails 5.2 and MiniTest standard.
rails generates a mail preview if you use rails g mailer CustomMailer . You will get a file CustomMailerPreview inside spec/mailers/previews folder. Here you can write your method that will call the mailer and it'll generate a preview.
Action Mailer is the Rails component that enables applications to send and receive emails. In this chapter, we will see how to send an email using Rails. Let's start creating an emails project using the following command. tp> rails new mailtest. This will create the required framework to proceed.
For me this issue came up because I defined the Devise Mailer Preview in the file devise_mailer_preview.rb
like this:
class Devise::MailerPreview < ActionMailer::Preview
in Rails 5 the convention though seems to use:
class DeviseMailerPreview < ActionMailer::Preview
This fixes the issue of disappearing Mailer Previews after editing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With