rails 3 + devise:如何使电子邮件确认链接使用安全https(不是http)

如何告诉Devise使用https(不是http)进行所有帐户确认和密码提醒等链接?

[注意:我不是在寻找将所有 http重定向到https的解决方案,我只需要设计以确保它创建的链接使用https]

我们的rails 3应用程序使用设计,并且应用程序在https下运行正常,但是,设计始终使用http作为电子邮件确认和密码链接它通过电子邮件发送给用户。

在我的环境文件中,我尝试更改:

config.action_mailer.default_url_options = { :host => "app1.mydomain.com" } 

  { :host => "https://app1.mydomain.com" } 

但可预测的设计会创建看起来像http://https//app1.mydomain.com ….的链接(例如,它预先设置:http::)的主机设置

default_url_options接受与url_for相同的哈希参数。 所以你应该能够做到这一点:

 config.action_mailer.default_url_options = { :protocol => 'https', :host => 'app1.mydomain.com' } 

要设置协议,还要设置子目录:

 config.action_mailer.default_url_options = { :host => "www.example.com", :protocol => 'https', :only_path => false, :script_name => "/app" #add this attribute if your app is deployed in a subdirectory } 

资源