I think you can use the devise_group option.
Example:
inside BlogsController (or any other controller, it doesn't matter which):
devise_group :blogger, contains: [:user, :admin]
Generated methods:
authenticate_blogger! # Redirects unless user or admin are signed in
blogger_signed_in? # Checks whether there is either a user or an admin signed in
current_blogger # Currently signed in user or admin
current_bloggers # Currently signed in user and admin
Use:
before_action :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page
current_blogger :user # Preferably returns a User if one is signed in
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…