简体   繁体   English

邮件预览无法正常工作

[英]mailer preview not working

My mailer is named send_invoice_mailer.rb (it works in dev and in prod). 我的邮件程序名为send_invoice_mailer.rb(它在dev和prod中工作)。

I want to be able to preview the send_checkout_invoice function using the mailer preview. 我希望能够使用邮件程序预览预览send_checkout_invoice函数。

routes.rb : 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 (not sure wich one is the correct one so I symlinked the file) /spec/mailers/previews/send_invoice_preview.rb和/test/mailers/previews/send_invoice_preview.rb(不确定哪一个是正确的,所以我对文件进行符号链接)

class SendInvoicePreview < ActionMailer::Preview

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

When I go to : /rails/mailers/send_invoice/send_checkout_invoice I am redirected to /fr/rails/mailers/send_invoice/send_checkout_invoice with this error: 当我去: /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"

EDIT : rails is 4.2 and this is done in dev with passenger. 编辑:rails是4.2,这是在乘客的开发中完成的。 App has been upgraded from previous rails versions multiple times. 应用程序已多次从以前的rails版本升级。

EDIT 2 : /rails/mailers also does not work. 编辑2:/ rails / mailers也不起作用。 Is it because of the locale scope? 是因为语言范围?

The location of the mailer previews directory can be configured using the preview_path option which has a default of test/mailers/previews: 可以使用preview_path选项配置邮件程序预览目录的位置,该选项具有默认的test / mailers / previews:

Try updating your configuration path for action mailer preview as below: 尝试更新动作邮件程序预览的配置路径,如下所示:

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

which fails if test directory was not in production. 如果测试目录未在生产中,则会失败。

Check this link, this may helps 检查此链接,这可能会有所帮助

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

I had a few routes at the end of routes.rb that caught all requests. 我在routes.rb的末尾有一些路由捕获了所有请求。 It works perfectly now. 它现在完美运作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM