基本上,我想在他/她注销时记录当前用户的内容。
我试图覆盖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
。< / p>
我该怎么办?我是否必须覆盖其他方法?喜欢:sign_out_and_redirect
?有更清洁的方法吗?
答案 0 :(得分:0)
您可以尝试以下方式:
before_filter :log_user_logout, only: [:destroy]
并在该方法中访问current_user