ruby-on-rails – 缺少带有{:locale => [:en],:formats => [:html]的模板布局/邮件程序,

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 缺少带有{:locale => [:en],:formats => [:html]的模板布局/邮件程序,前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在关注michael harlt rails教程,但是我收到了这个错误

Missing template layouts/mailer with {:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:raw,:erb,:html,:builder,:ruby,:coffee,:jbuilder]}. Searched in: * “/home/ubuntu/workspace/app/views”

预览帐户激活时

这是我的user_mailer.rb

class UserMailer < ApplicationMailer

  def account_activation(user)
    @user = user
    mail to: user.email,subject: "Account activation"
  end

  def password_reset
    @greeting = "Hi"

    mail to: "to@example.org"
  end
end

并且错误突出显示的行

mail to: user.email,subject: "Account activation"

我尝试在user_mailer.rb中添加layout’mailer’,但它不起作用.

编辑:
Here is the screenshot of the error

The screenshot of my folders

解决方法

如果您还没有,则需要名为user_mailer的视图中的文件夹,并且您需要为每个方法(account_activation.html.erb& password_reset.html.erb)提供一个文件.这是您的电子邮件模板的位置.

猜你在找的Ruby相关文章