【问题标题】:Rails 5 mailer preview with Rspec带有 Rspec 的 Rails 5 邮件程序预览
【发布时间】:2017-04-28 12:07:35
【问题描述】:

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

我总是收到此错误:找不到邮件预览“user_mailer”

spec/previews/user_mailer_preview.rb

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

我尝试添加:

config.action_mailer.preview_path = "#{Rails.root}/spec/previews"

但是没有用。

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

【问题讨论】:

标签: ruby-on-rails ruby email rspec


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    另一种选择是将environments/development.rb 中的路径更改为:

    config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
    

    【讨论】:

      猜你喜欢
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-02
      • 2014-07-29
      • 1970-01-01
      相关资源
      最近更新 更多