ActionView::MissingTemplate: Missing template signup_mailer/welcome_message with "mailer". Searched in: * "signup_mailer"
Asked Answered
T

1

8

I am using Sidekiq to deliver my emails asynchronously but have had persistent errors about not being able to find the email template. It isn't consistent as it works from time to time (like when I'm testing). You can see that I have even tried specifying the path and name of the template.

The error I am receiving in Honeybadger is: ActionView::MissingTemplate: Missing template signup_mailer/welcome_message with "mailer". Searched in: * "signup_mailer"

app/mailers/signup_mailer.rb

class SignupMailer < ActionMailer::Base
  default from: '[email protected]'

  def welcome_message(company, user)
    @company = company
    @user = user
    @web_url = root_url
    mail(to: @company.email, subject: 'Welcome to CompanyCam', template_path: 'signup_mailer', template_name: 'welcome_message')
  end
end

You can see in the picture that there is in fact a view called welcome_message.html.erb and the text version as well located in app/views/signup_mailer/ enter image description here

Torrefy answered 26/8, 2016 at 14:53 Comment(9)
change from mail(to: @company.email, subject: 'Welcome to CompanyCam', template_path: 'signup_mailer', template_name: 'welcome_message') => to mail(to: @company.email, subject: 'Welcome to CompanyCam')Undersigned
That is what I had originally, but it still didn't work. That is why I tried manually setting the info.Torrefy
Do any of the potential solutions here work for you?Torque
Unfortunately I have tried them all and it doesn't work. Side note, this is in ProductionTorrefy
Did you try to restart Sidekiq? Maybe it's still working with an old version of your code? Please connect to your rails console and try to execute SignupMailer.welcome_message(random_company, random_user)Weaks
@Weaks I have restarted Sidekiq, but I did just try executing that from the Rails Console and received the error. Any other idea?Torrefy
I tried your code and I got the error because my file was named welcome_message.html.erb.rb but then I fixed it. Do you have gems like haml which may break the render of erb file?Weaks
@Weaks nope no render modifications.Torrefy
How did you solved it? I'm hitting a similar wall and wondering... in my case the name in the template_name is not being considered.Smoothie
M
0

Can you try this out.

class SignupMailer < ActionMailer::Base
  default from: '[email protected]' 
  layout "welcome_message"

  def welcome_message(company, user)
    @company = company
    @user = user
    @web_url = root_url
    mail(to: @company.email, subject: 'Welcome to CompanyCam')
  end
end
Marsha answered 10/9, 2016 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.