Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailer missing template rail-api application #220

Open
sumit20rai opened this issue Oct 10, 2016 · 1 comment
Open

Mailer missing template rail-api application #220

sumit20rai opened this issue Oct 10, 2016 · 1 comment

Comments

@sumit20rai
Copy link

I have rails-api application, i want to send welcome email to the customer.
I have a method called send_welcome_email in customer_mailer.rb

 def send_welcome_email(user)
    email = "noreply@getsavvy.in"
    mail(to:"#{user.email}", from:email ,subject:"Thanks for signing up") 
  end

and in customer.rb iam calling

def send_welcome_mail
    CustomerMailer.send_welcome_email(self).deliver_now
 end

I also have an send_welcome_email.html.erb template in app/views/customer_mailer/
I am getting following error
CustomerMailer#send_welcome_email: processed outbound mail in 77.7ms
ActionView::MissingTemplate: Missing template customer_mailer/send_welcome_email with "mailer". Searched in:

  • "customer_mailer"

Any idea what am I doing wrong here?

@Midnighter
Copy link

Midnighter commented Dec 19, 2016

I generated a clean new app using rails 4.2.7 and rails-api. This has pointed me to these problems with my main app that I was developing:

Layout Files

I had the same problem with missing templates being reported and then saw that with a normal rails 4.2.7 application two more files are created with any bin/rails g mailer call:

  • app/views/layouts/mailer.text.erb
  • app/views/layouts/mailer.html.erb
    if you copy over or otherwise generate those files, suddenly the templates are found.

mailer.text.erb content:

<%= yield %>

mailer.html.erb content:

<html>
  <body>
    <%= yield %>
  </body>
</html>

Spring

Issues #23 and #147 suggest disabling spring. At the time of this writing this can be done in two steps:

  • bin/spring binstub --remove --all
  • Remove spring from your Gemfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants