在ApplicationController中覆盖current_user会引发未定义的方法错误

基于stackoverflow问题来覆盖devise的current_user,我写了这样的东西:

class ApplicationController < ActionController::Base alias_method :devise_current_user, :current_user def current_user if !devise_current_user.nil? return # my logic end return nil end end 

两个问题:1。它抛出了一个未定义的方法错误,我定义了alias_method …. 2.在devise_for方法中,我的覆盖current_user将被传递还是设计的current_user?