在密码重置和帐户激活中发送的链接会在电子邮件中发送,但当我点击它们时,它们不会被重定向到我的Heroku应用程序,浏览器会被困在"about:black"。我是不是错过了什么?它们看起来像这样:
<a href="https://u1655481.ct.sendgrid.net/wf/click?upn=mvuowIo3LtfxyVBtmnV5znO-2BvLApX4OWlh043PlY34nTdRmVM6vveMB03kyw9RkDUEvA28BSK-2BUBSWODF5yWFrC-2BNt0QPl2osMcVH1xzWtqraK-2BhdDaKAPwzziqS4B54pYcNarDcDTbKmyaLj-2BTSmnoiNl2BT8VqnMMrP7p8su4-3D_MQpxKXFxFonjeh1cARHVt6njcLV6H54PXEoHxOAloIou4oLyvkm9uLyulhz86uohdzxbBJHb-2Bu9ZUCPw-2FkxT7fW8mZO5dW2jHztjZZckPwUqZd9lZaxI8eitFNUyzb6GNUFVejIw76kkAOqYCQ5M4cZXTVJClAoWekh6xUxZ9NUOMK-2B-2Fx5D-2BfOqUmHW462oyh61psTTWPiu0GRg2HpWs0NezfSCN6Kh938A8OJLHBUQ-3D" target="_blank" class="">Reset password</a>
这是我的应用程序/views/user_mailer/password_reset.html.erb
<h1>Password reset</h1>
<p>To reset your password click the link below:</p>
<%= link_to "Reset password", edit_password_reset_url(@user.reset_token,
email: @user.email) %>
<p>This link will expire in two hours.</p>
<p>
If you did not request your password to be reset, please ignore this email and
your password will stay as it is.
</p>
看起来您传递给SendGrid的URL是http://<your+heroku+app>.herokuapp.com/password_resets/...
,因此您需要确保指定应用程序的名称,而不是http://<your+heroku+app>
。如果您使用SMTP,请检查您的config.action_mailer.default_url_options(在config/production.rb
中)设置是否正确:
config.action_mailer.default_url_options = { :host => 'http://appname.herokuapp.com' }
也犯了同样的错误,当我意识到解决方案时,我感到非常失望:
-
查看
config/environments/production.rb
清单10.56 -
用你的应用程序名称更新
host = '<your+heroku+app>.herokuapp.com'
(在我的情况下是host = 'twitterdave.herokuapp.com'
)
让我知道它是否有助于