Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action not found in Mailer preview

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.

like image 334
pastullo Avatar asked Nov 17 '18 13:11

pastullo


People also ask

How do I Preview Mailer in Rails?

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.

What is action mailer?

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.


1 Answers

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.

like image 178
snrlx Avatar answered Oct 19 '22 02:10

snrlx