require 'request_store' module ExpressAdmin module CurrentUser def self.included(base) base.class_eval do include InstanceMethods before_action do set_current_user end end end module InstanceMethods def set_current_user if defined? Devise # This allows `current_user` (if defined) to be accessible # outside a controller. RequestStore[:current_user] = self.try(:current_user) end end end end end