使用Rspec进行Rails 5邮件预览

BoB*_*BoB 2 ruby email rspec ruby-on-rails

我无法在http:// localhost:3000/rails/mailers/user_mailer中预览我的电子邮件

我总是收到此错误:未找到邮件程序预览'user_mailer'

规格/预览/ user_mailer_preview.rb

class UserMailerPreview < ActionMailer::Preview
  def contact_form
    UserMailer.contact_form("john@example.com", "John", "Hello World!")
  end
end
Run Code Online (Sandbox Code Playgroud)

我试着添加:

config.action_mailer.preview_path = "#{Rails.root}/spec/previews"
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

任何想法如何解决这个问题?

Bri*_*ian 5

尝试将文件移动到spec/mailers/previews/user_mailer_preview.rb.