缺少带有 {:locale=>[:en]、:formats=>[:html]、的模板布局/邮件程序, [英] Missing template layouts/mailer with {:locale=>[:en], :formats=>[:html],
问题描述
我正在关注 michael harlt rails 教程,但出现此错误
I'm following michael harlt rails tutorial but i get this error
缺少带有 {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, 的模板布局/邮件程序:builder, :ruby, :coffee, :jbuilder]}.搜索: * "/home/ubuntu/workspace/app/views"
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
This is my 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 中添加布局mailer",但它不起作用.
I tried adding layout 'mailer' in user_mailer.rb but it doesn't work.
推荐答案
如果您还没有,您将需要一个名为 user_mailer 的视图中的文件夹,并且在其中您需要为每个方法创建一个文件 (account_activation.html.erb 和 password_reset.html.erb).这是您的电子邮件模板所在的位置.
If you don't already, you will need a folder within views called user_mailer and within that you will need a file for each of those methods (account_activation.html.erb & password_reset.html.erb). This is where the template of your email will be.
这篇关于缺少带有 {:locale=>[:en]、:formats=>[:html]、的模板布局/邮件程序,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!