邮件预览无法正常工作

时间:2017-07-04 17:19:04

标签: ruby-on-rails routing actionmailer

我的邮件程序名为send_invoice_mailer.rb(它在dev和prod中有效)。

我希望能够使用邮件程序预览功能预览send_checkout_invoice函数。

routes.rb:

scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
  #app routes
end

/spec/mailers/previews/send_invoice_preview.rb AND /test/mailers/previews/send_invoice_preview.rb(不确定哪一个是正确的,所以我对文件进行了符号链接)

class SendInvoicePreview < ActionMailer::Preview

  def send_checkout_invoice
    #initializing foo
    SendInvoice.send_checkout_invoice(foo)
  end
end

当我转到:/rails/mailers/send_invoice/send_checkout_invoice我被重定向到/fr/rails/mailers/send_invoice/send_checkout_invoice并出现此错误:

No route matches [GET] "/fr/rails/mailers/send_invoice/send_checkout_invoice"

编辑:rails是4.2,这是在乘客的dev中完成的。应用程序已多次从以前的rails版本升级。

编辑2:/ rails / mailers也不起作用。是因为语言环境范围?

2 个答案:

答案 0 :(得分:3)

可以使用preview_path选项配置邮件程序预览目录的位置,该选项默认为test / mailers / previews:

尝试更新动作邮件程序预览的配置路径,如下所示:

app:actionViewClass

如果测试目录未在生产中,则会失败。

检查此链接,这可能会有所帮助

https://richonrails.com/articles/action-mailer-previews-in-ruby-on-rails-4-1

答案 1 :(得分:0)

我在routes.rb的末尾有一些路由捕获了所有请求。它现在完美无缺。

相关问题