Rails3 +设计:edit_password_url 输出 http://www.blah.com (http 没有冒号!)
当用户从我们的生产服务器收到我们应用程序中的更改密码链接的邮件时,无论出于何种原因,他们都会获得一个不带冒号 http:// 的绝对 URL。结果,人们抱怨该链接不起作用。
该问题仅发生在我的生产环境中,但我确实在 /config/environments/development.rb
中设置了此设置:
config.action_mailer.default_url_options = { :host => 'http://www.blah.com' }
所以我不确定问题可能是什么。我还在整个网站上搜索了字符串“http//”,看看它是否只是某个地方设置中的拼写错误,但没有骰子。
confirmation_instructions.html.erb
本身未受影响,链接是这样生成的:
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
那么到底是什么原因导致我的服务器从 http:// 中删除 : ?以前有人遇到过这个问题吗?有关如何修复它的任何理论吗?提前致谢!
When a user gets mailed the change password link in our app from our production server, for whatever reason, they're getting an absolute url without the colon the http://. As a result, people are complaining the link doesn't work.
The issue only occurs on my production environment, but I do have this set in /config/environments/production.rb
:
config.action_mailer.default_url_options = { :host => 'http://www.blah.com' }
So I'm not sure what the issue could be. I've also searched the entire site for the string "http//" to see if it was just a typo in a setting someplace, but no dice.
The confirmation_instructions.html.erb
itself is untouched and the link is generated as such:
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
So what the crap would cause my server to drop the : from http://?? Has anyone ever run across this issue before? Any theories on how to fix it? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了这个问题。问题(奇怪)是您在 default_url_options 中使用了完整的 URL (:host => 'http://www.blah.com')。如果你输入 www.blah.com ,它似乎可以工作。我昨晚遇到了这个问题,这对我来说是最快的解决方法。
I ran into this problem too. The issue (oddly) is that you're using a full URL in the default_url_options (:host => 'http://www.blah.com'). If you put www.blah.com instead it appears to work. I ran into this problem last night and this was the quickest fix for me.
创建新的邮件程序扩展 Devise::Mailer 并覆盖他的方法:
接下来转到 config/initializers/devise.rb 并删除 config.mailer 之前的哈希值
在这个地方设置您自己的邮件程序。
就这样
Create new mailer extended Devise::Mailer and override his methods:
Next go to config / initializers / devise.rb and remove hashes before config.mailer
Set in this place your own mailer.
Thats all