Devise 忘记密码正在产品上创建与本地主机的链接?
我们正在使用标准设备忘记密码邮件程序:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
在生产中,这会生成用于更改密码的本地主机 url:
http://localhost:3000/users/password/edit?reset_password_token=amqs2q9NcM1FerHKhmzV
考虑到 production.rb 文件具有我们的域,这很奇怪:
config.action_mailer.default_url_options = { :host => 'mysite.com' }
为什么 URL 中没有使用 mysite.com?有想法吗?
谢谢
We're using the standard devise forgot password mailer:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
On production this is generating a localhost url for Change Password:
http://localhost:3000/users/password/edit?reset_password_token=amqs2q9NcM1FerHKhmzV
This is strange given the production.rb file has our domain:
config.action_mailer.default_url_options = { :host => 'mysite.com' }
Why is mysite.com not being used in the URL? Ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是
config.action_mailer.default_url_options
正在某处被覆盖。config/initializers
中是否有影响ActionMailer
的文件?尝试在生产环境中运行
rails console
并查看返回结果。
My guess is that
config.action_mailer.default_url_options
is being overwritten somewhere. Do you have any file inconfig/initializers
that affectsActionMailer
?Try running
rails console
on your production box and see whatreturns.
我的问题出在 config/initializers/setup_mail.rb
My problem was in config/initializers/setup_mail.rb
我通过简单地将
port
添加到config.action_mailer.default_url_options
来修复此问题,Devise 在安装过程中总是告诉我们这样做,但我们很多人都忽略了它。无论如何,这是用于
development.rb
的。在生产中,端口的值将是一个变量 -
$PORT
,cos Heroku 动态生成端口。I fixed this by simply adding
port
toconfig.action_mailer.default_url_options
which Devise always tells us to do during installation but many of us ignore it.this is for
development.rb
anyway.In production the value of the port will be a variable -
$PORT
, cos Heroku dynamically generates the port.