Ruby on rails 配置开信器预览路径

Ruby on rails 配置开信器预览路径,ruby-on-rails,Ruby On Rails,在我的项目中,我们有test和spec文件夹,因为我们正在尝试从minitest迁移到rspec 我现在正试图预览我正在设计的邮件器的布局,所以我创建了一个预览邮件器。问题是,它要求我将邮件预览放在test/mailers/xx路径中,否则它将找不到它们 有没有办法让rails在spec文件夹中搜索邮件预览 这就是我所说的预览: # Preview at http://localhost:3000/rails/mailers/reporting/iue/report_mailer/name cl

在我的项目中,我们有
test
spec
文件夹,因为我们正在尝试从minitest迁移到rspec

我现在正试图预览我正在设计的邮件器的布局,所以我创建了一个预览邮件器。问题是,它要求我将邮件预览放在
test/mailers/xx
路径中,否则它将找不到它们

有没有办法让rails在
spec
文件夹中搜索邮件预览

这就是我所说的预览:

# Preview at http://localhost:3000/rails/mailers/reporting/iue/report_mailer/name
class Reporting::IUE::ReportMailerPreview < ActionMailer::Preview
  def report
    report = FactoryBot.create(:reporting_iue_report)
    FactoryBot.create_list(:reporting_iue_report_section, 3, report: report)
    Reporting::IUE::ReportMailer.report(report)
  end
end
#预览http://localhost:3000/rails/mailers/reporting/iue/report_mailer/name
类报告::IUE::ReportMailerPreview

谢谢大家!

信函开启器的默认设置实际上将临时邮件测试存储在
tmp/letter\u opener
中。这告诉我,在您的配置中,路径设置为转到
test
目录。我会寻找一个初始化文件或指定它的东西

否则,您可以创建自己的文件,例如
初始值设定项/letter_opener.rb
,并将以下内容放入其中:

LetterOpener.configure do |config|
  # To overrider the location for message storage.
  # Default value is <tt>tmp/letter_opener</tt>
  config.location = Rails.root.join('spec', 'mailers')
end
我已经添加了工厂机器人行,因为你提到了使用它

更新2:

要更改邮件预览的路径,我相信您可以通过将以下内容添加到
config/applications.rb
文件中来实现:

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

请在中查看更多信息。

尝试此
config.action\u mailer.preview\u path=“#{Rails.root}/spec/mailer\u previews”

或者类似的。有些文档…

但是tmp路径是存储已经创建的电子邮件的地方,对吗?我说的是你将工厂机器人程序代码用于生成测试记录的路径,然后邮寄者将使用你让我意识到我所使用的并不是信件开启器的功能,所以谢谢你!但工厂机器人这件事其实不是我的问题。即使预览电子邮件位于
test
文件夹和
spec
上的工厂中,它仍然有效。问题是,我希望我的预览也能在规范中找到folder@LeticiaEsperon-哦,知道了。请参阅更新2.:)就这样!上次配置完成了。非常感谢。是的!那是答案,但约翰先回答说:谢谢!
config.action_mailer.preview_path = "#{Rails.root}/spec/mailer_previews"