Rails邮件程序预览不适用于规格/邮寄/预览
我希望能够在浏览器中预览我的电子邮件。
我正在使用Rspec并在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
当我尝试访问它时,我收到以下错误:
AbstractController::ActionNotFound at /rails/mailers/employee_mailer Mailer preview 'employee_mailer' not found
但是,当我将测试/邮件/预览中的预览代码放入其中时,它可以工作。
如何配置我的Rails应用程序以查找spec / mailers / previews中的预览?
使用
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
在config/application.rb
中定义预览所在的路径。