基本上,我想在她/他注销时记录有关当前用户的一些信息。
我正在尝试覆盖after_sign_out_path_for
:
def after_sign_out_path_for(user)
# Notice that differently from +after_sign_in_path_for+ this method
# receives a symbol with the scope, and not the resource.
# puts current_user.id
new_user_session_path
end
但是该方法current_user
有时会返回nil
,并且从这张票(https://github.com/plataformatec/devise/pull/2022)看来,它似乎current_user
在after_sign_out_path_for
.
我应该怎么办?我必须覆盖其他方法吗?喜欢:sign_out_and_redirect
?有更清洁的方法吗?