我也有同样的问题,下面的代码似乎适合我.
假设密码控制器是为单例路由设置的.另外,假设经过身份验证的模型是一个帐户.有了这些,你就有了以下几点:
def update
if current_account.update_with_password(params[:account])
sign_in(current_account, :bypass => true)
flash[:notice] = 'Password updated.'
redirect_to account_path
else
render :action => :show
end
end
关键的组成部分是sign_in方法调用,它试图重新登录帐户,但绕过典狱长回调并将帐户存储到会话中.