rails 3 + devise:如何使电子邮件确认链接使用安全的https(不是http) [英] rails 3 + devise: how do I make the email confirmation links use secure https (not http)
问题描述
如何告诉Devise对所有的帐户确认和密码提醒等链接使用https(不是http)?
How to I tell Devise to use https (not http) for all the account confirmation and password reminder etc links?
[注意:我不是在寻找一个将全部 http重定向到https的解决方案,我只需要设计来确保其创建的链接使用https]
[note: I'm not looking for a solution to redirect all http to https, I just need devise to ensure the links it creates use https]
我们的rails 3应用程序使用devise ,并且应用程序在https下运行正常,但是,设计总是使用http进行电子邮件确认和密码将其发送给用户。
Our rails 3 app uses devise, and the app runs fine under https, however, devise always uses http for the email confirmation and password links it emails to users.
在我们的环境文件中,我尝试更改:
In our environment files I tried changing:
config.action_mailer.default_url_options = { :host => "app1.mydomain.com" }
到
{ :host => "https://app1.mydomain.com" }
但可预测的设计会创建看起来像
http://https//app1.mydomain.com ....(例如,它添加了:使用http:的主机设置)
but predictably devise creates links that look like http://https//app1.mydomain.com.... (eg, it prepends the :host settings with http:)
推荐答案
default_url_options
接受与 url_for
。所以你应该可以这样做:
default_url_options
accepts the same hash parameters as url_for
. So you should be able to do this:
config.action_mailer.default_url_options = { :protocol => 'https', :host => 'app1.mydomain.com' }
这篇关于rails 3 + devise:如何使电子邮件确认链接使用安全的https(不是http)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!