ActionView::MissingTemplate(缺少模板 layouts/base_mailer

ActionView::MissingTemplate (Missing template layouts/base_mailer

我想要确认邮件,用户在完成他的过程后会收到它。我把它分成两个 类 - BaseMailerConfirmationMailer < BaseMailer。我试图在 rails 控制台中调用它,但收到错误消息:

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

代码如下:

BaseMailer

class BaseMailer < ApplicationMailer
  layout 'base_mailer'
  default from: "testing@test.com"
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

我的观点结构:

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

您忘记创建 app/views/layouts/base_mailer.html.erb