Search code examples
ruby-on-railsrubyruby-grape

ActionView::MissingTemplate (Missing template layouts/base_mailer


I want to have confirmation mailer, which user receive it after finished his process. I split it into two classes - BaseMailer and ConfirmationMailer < BaseMailer. I was trying to call it in the rails console but I've received an error:

ActionView::MissingTemplate (Missing template layouts/base_mailer with {:locale=>[:en, :de], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:)

Code below:

BaseMailer

class BaseMailer < ApplicationMailer
  layout 'base_mailer'
  default from: "[email protected]"
end

ConfirmationMailer

class ConfirmationMailer < BaseMailer
  layout 'base_mailer'

  def send_email(to_email, cc_email)
    mail_headers = headers(to_email, cc_email)
    mail(mail_headers)
  end

  private

  def headers(to_email, cc_email)
    {
      to: to_email,
      cc: cc_email,
      reply_to: to_email,
      subject: 'testing title',
    }
  end
end

Structure of my views:

views
  |__base_mailer
  |        |___welcome.html.erb
  |
  |__confirmation_mailer
           |___send_email.html.erb

Solution

  • You forgot to create app/views/layouts/base_mailer.html.erb