Override current_user in ApplicationController throws undefined method error

。_饼干妹妹 提交于 2020-01-02 09:45:29

问题


Based on stackoverflow question for overriding current_user of devise, I wrote something like this:

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

Two questions: 1. It throws an undefined method error where I define alias_method .... 2. In the devise_for method, will my overriden current_user will be passed or the devise's current_user?

来源:https://stackoverflow.com/questions/12465324/override-current-user-in-applicationcontroller-throws-undefined-method-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!