Using Authority with Devise and multiple user models
Clone this wiki locally
The Devise authentication gem allows you to have multiple types of users. For example, you might have
current_user for some controllers and
current_admin for others.
Authority currently only supports a single method for getting the current user; whatever you put in
config.user_method, it will expect to be able to call that method on any controller in your app.
However, you can easily adapt to this requirement using method aliases. For example:
# config/initializers/authority.rb config.user_method = :user_for_this_request # or whatever; default is :current_user # app/controllers/users_controller.rb class UsersController < ApplicationController alias :user_for_this_request :current_user end # app/controllers/admins_controller.rb class AdminsController < ApplicationController alias :user_for_this_request :current_admin end # app/controllers/secret_things_controller.rb class SecretThingsController < AdminsController end