rails 4 中在本地工作但不在 heroku 上工作时如何解决忘记密码的问题
how to solve forgot password when working on local but not working on heroku for devise in rails 4
我正在使用 rails 4 和 ruby 2。我已经使用 devise 实现了登录。我的问题是忘记密码在 heroku 上不起作用,但在本地工作。当我点击 "Change my password" link 收到邮件后,它会重定向到 https://www.heroku.com/ 页面。我该如何解决这个问题?如果有人有任何想法,请帮助我。
代码:
reset_password_instructions.html.erb:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. 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>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
检查您是否在 config/application.rb
:
中配置了服务器的 url
config.action_mailer.default_url_options = { host: 'your.example.com' }
在 Rails Guide about Mailers 中查找更多详细信息。
在你的 config/environments/production.rb 文件中,你应该看起来像
config.action_mailer.default_url_options = { :host => "http://eee.com" }
它定义了在使用 Rails url 助手解析 url 时动作邮件程序使用的 url。因此,如果您设置或更改此值,它应该会更改结果。
我正在使用 rails 4 和 ruby 2。我已经使用 devise 实现了登录。我的问题是忘记密码在 heroku 上不起作用,但在本地工作。当我点击 "Change my password" link 收到邮件后,它会重定向到 https://www.heroku.com/ 页面。我该如何解决这个问题?如果有人有任何想法,请帮助我。
代码:
reset_password_instructions.html.erb:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. 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>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
检查您是否在 config/application.rb
:
config.action_mailer.default_url_options = { host: 'your.example.com' }
在 Rails Guide about Mailers 中查找更多详细信息。
在你的 config/environments/production.rb 文件中,你应该看起来像
config.action_mailer.default_url_options = { :host => "http://eee.com" }
它定义了在使用 Rails url 助手解析 url 时动作邮件程序使用的 url。因此,如果您设置或更改此值,它应该会更改结果。