本文介绍了规范/邮件程序/预览版中不提供 Rails 邮件程序预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够在浏览器中预览我的电子邮件.
I would like to be able to preview my emails in the browser.
我正在使用 Rspec 并在 spec/mailers/previews 中有以下预览设置:
I am using Rspec and have the following preview setup in spec/mailers/previews:
# Preview all emails at http://localhost:3000/rails/mailers/employee_mailer
class EmployeeMailerPreview < ActionMailer::Preview
def welcome
Notifier.welcome_email(Employee.first)
end
end
当我尝试访问它时,出现以下错误:
When I try to access this I get the following error:
AbstractController::ActionNotFound at /rails/mailers/employee_mailer
Mailer preview 'employee_mailer' not found
但是,当我将预览代码放在测试/邮件程序/预览中时它有效.
However, when I put the code for the preview inside of tests/mailers/previewsit works.
如何配置我的 Rails 应用以在 spec/mailers/previews 中查找预览?
How can I configure my Rails app to look for the previews inside of spec/mailers/previews?
推荐答案
使用
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
在 config/development.rb
中定义预览所在的路径.
in config/development.rb
to define the path where previews are located.
这篇关于规范/邮件程序/预览版中不提供 Rails 邮件程序预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!