ActionView :: MissingTemplate(缺少模板布局/ base_mailer

问题描述 投票:0回答:1

我想要一个确认邮件,该邮件在完成处理后由该用户接收。我将其分为两类-BaseMailerConfirmationMailer < BaseMailer。我试图在Rails控制台中调用它,但收到一个错误:

ActionView :: MissingTemplate(缺少模板布局/ base_mailer,带有{:locale => [:en,:de],:formats => [:html],:variants => [],:handlers => [:raw, :erb,:html,:builder,:ruby,:coffee,:jbuilder]}。在以下位置搜索:)

下面的代码:

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

我的观点结构:

views
  |__base_mailer
  |        |___welcome.html.erb
  |
  |__confirmation_mailer
           |___send_email.html.erb
ruby-on-rails ruby grape
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.