Rails _url 助手和 force_ssl

Rails _url helper and force_ssl

我在 production.rb 中有以下内容:

config.force_ssl = true

现在,当使用

path_to_page_url(@record)

在电子邮件中,生成的 url 如下所示:

https://example.com

超时。

但是,https://www.example.com不会超时。

有什么方法可以将 "www" 前缀添加到 url 助手?

在production.rb文件中添加:

config.action_mailer.default_url_options = { host: 'www.example.com', protocol: 'https'}