【问题标题】:Actionmailer URL adds subdir twiceActionmailer URL 两次添加子目录
【发布时间】:2017-09-08 17:31:33
【问题描述】:

我有一个非常标准的 rails 5.1 应用程序,它安装在我们主域下的子目录下:

https://www.company.com/subir/

这是在 routes.rb 中完成的

scope :subdir 
  the other routes
end

我在 DMZ 中使用 NGINX 将传入请求传递给我的应用程序服务器:

...
server_name www.company.com;

 location /subdir {
   proxy_pass https://my-app-server;
 }
...

在我的应用服务器上安装了非常常见的 Nginx/Puma 组合,几乎一切正常,除了我通过 actionmailer 发送的电子邮件中的网址。

在我看来,我有一个链接:

link_to 'approve customer', admin_customer_url(@customer) 

这将创建以下内容:

https://www.company.com/**subdir/subdir**/admin/customer/:id

在我的本地机器上,这些链接是在我的电子邮件中正确生成的,但不是在我的应用服务器上的暂存环境中。

我将请求对象转储到视图中,以查看我的 nginx 设置是否疯狂,但没有任何明显的疯狂......

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails nginx actionmailer


    【解决方案1】:

    检查您的环境文件中是否设置了 config.action_mailer.default_url_options。 http://api.rubyonrails.org/classes/ActionMailer/Base.html

    【讨论】:

    • 是:config.action_mailer.default_url_options = { 主机:'company.com'}
    【解决方案2】:

    记录:在 deploy/staging.rb 我仍然导出了 ENV['RAILS_RELATIVE_URL_ROOT']。这将 subdir 添加到 app.base_path 两次,这导致了我的问题。

    【讨论】:

      猜你喜欢
      • 2015-12-06
      • 1970-01-01
      • 1970-01-01
      • 2021-09-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 2015-11-22
      • 1970-01-01
      相关资源
      最近更新 更多