邮件模板丢失

templates missing with mailer

我刚开始使用邮件程序并阅读了一些教程,但我终究无法弄清楚为什么会出现此错误

Missing template layouts/mailer with {:locale=>[:en], :formats=>[:text], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :haml]}. Searched in:
  * "/Users/paulmcguane/RoR/barista/app/views"
  * "/Users/paulmcguane/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/devise-3.5.6/app/views"

new_record_notification.text.erb

Hi,

A new record has been added: <%= @record.name %>

Thanks

model_mailer.rb

class ModelMailer < ApplicationMailer

  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:
  #
  #   en.model_mailer.new_record_notification.subject
  #
  def new_record_notification(record)
    @record = record
    mail(to: 'email@address') do |format|
      format.text
    end
  end
end

很可能您在 ApplicationMailer class 中使用布局 'mailer'。使用现有布局或根本不使用布局。