我的邮件程序名为 send_invoice_mailer.rb(它可以在开发和产品中使用)。
我希望能够使用邮件预览来预览 send_checkout_invoice 函数。
路线.rb:
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
#app routes
end
/spec/mailers/previews/send_invoice_preview.rb 和/test/mailers/previews/send_invoice_preview.rb (不确定哪一个是正确的,所以我符号链接(symbolic link)了该文件)
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,这是在开发中与乘客一起完成的。应用程序已从以前的 Rails 版本多次升级。
编辑2:/rails/mailers 也不起作用。是因为语言环境范围吗?
最佳答案
可以使用 Preview_path 选项配置邮件预览目录的位置,该选项默认为 test/mailers/previews:
尝试更新操作邮件预览的配置路径,如下所示:
config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
如果测试目录不在生产环境中,则会失败。
检查此链接,这可能会有所帮助
https://richonrails.com/articles/action-mailer-previews-in-ruby-on-rails-4-1
关于ruby-on-rails - 邮件预览无法正常工作,因为没有路由匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44911339/