Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "Action Mailer" is not rendering the email template?

I am using "Action Mailer" in Ruby on Rails application to send emails. I have the following action mailer:

class SecurityUserMailer < ActionMailer::Base

  default from: '[email protected]'

  def password_reset(security_user)
    @security_user = security_user
    mail to: security_user.email, subject: 'Password Reset'
  end

  def email_confirmation(security_user)
    @security_user = security_user
    mail to: security_user.email, subject: 'Account Created'
  end

end

I am successfully sending emails but the second method (email_confirmation) is not using the corresponding template.

The email templates are in views/security_users_mailer folder and named as follows:

  1. email_confirmation.txt.erb
  2. password_reset.txt.erb

Why only the password_reset template is used?

Note, firstly, I thought that maybe there is something wrong with the code in my template but then I replace it with text content and it is not rendered again.

like image 588
gotqn Avatar asked Jan 13 '23 03:01

gotqn


1 Answers

Rails 4 I had this same issue, but mine was caused by having an empty layout in layouts/mailer.html.erb

like image 60
lfender6445 Avatar answered Jan 19 '23 00:01

lfender6445