我确实在 localhost:3000 上使用确认电子邮件进行注册。在我的development.rb中我添加这样的
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => '587',
:authentication => :plain,
:user_name => '[email protected]',
:password => 'mypassword',
:domain => 'localhost:3000',
:enable_starttls_auto => true
}
当我注册时,我打开我的电子邮件,然后在收件箱中显示消息您可以通过以下链接确认您的帐户电子邮件:确认我的帐户,我单击此链接。它重定向到 localhost:3000/users/sign_in 并且我可以成功登录。但是当我再次在收件箱中单击此链接(确认我的帐户)时。它显示如下错误:
网址:
http://localhost:3000/users/confirmation?confirmation_token=dWUeHVP_N7VzsVwvkNW5
消息错误:
Resend confirmation instructions
1 error prohibited this user from being saved:
Confirmation token is invalid
在我的电子邮件收件箱中,当我再次单击链接“确认我的帐户”时,我希望它重定向到 localhost:3000/users/sign_in。再次单击链接“确认我的帐户”时,如何重定向到 localhost:3000/users/sign_in ?请帮助我!
在确认confirmation_token变为nil并导致此错误后,您只能使用一次确认链接。如果您想在确认已完成的情况下将某人重定向到登录网址。然后你需要重写设备确认控制器。
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_flashing_format?
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
redirect_to new_user_session_path
#respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
null&令牌=20231017232713&确认=y 是的,我确实想收到余额通知(确认注册的链接)