This blog is part of our Rails 5.2 series.
Rails has inbuilt feature to preview the emails using Action Mailer previews.
A preview mailer can be setup as shown here.
This will work as expected. But our email template is displayed differently based on user’s role. To test this, we need to update the notify method and then check the updated preview.
What if we could just pass the email in the preview URL.
In Rails 5.2, we can pass the params directly in the URL and params will be available to the preview mailers.
Our code can be changed as follows to use the params.
This allows us to test our mailers with dynamic input as per requirements.