I want that only my users who have their attribute is_admin set to true to be able to access my active admin backend
how should I do this?
“Normal” users should only be able to login to the site, not to active admin.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In
config/initializers/active_admin.rbyou have such config:so if you create a method named authenticate_admin_user! in the ApplicationController, then ActiveAdmin will check if the user can go to the admin pages or not. Like this:
and rescue from that exception in ApplicationController (or you can actually redirect inside the
authenticate_admin_user!method)And one more small thing, if you don’t have admin_users, then it would be nice to change this line in
config/initializers/active_admin.rb:And with devise you might want to make the default path different for admin/non-admin users, so you can define
after_sign_in_path_formethod in the controller