0

基本上,我想在她/他注销时记录有关当前用户的一些信息。

我正在尝试覆盖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_userafter_sign_out_path_for.

我应该怎么办?我必须覆盖其他方法吗?喜欢:sign_out_and_redirect?有更清洁的方法吗?

4

1 回答 1

0

您可以尝试以下方法:

before_filter :log_user_logout, only: [:destroy]

current_user在该方法内访问

于 2013-11-06T00:56:52.533 回答