Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7535619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:20:58+00:00 2026-05-30T06:20:58+00:00

I want that only my users who have their attribute is_admin set to true

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:20:59+00:00Added an answer on May 30, 2026 at 6:20 am

    In config/initializers/active_admin.rb you have such config:

    config.authentication_method = :authenticate_admin_user!
    

    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:

    # restrict access to admin module for non-admin users
    def authenticate_admin_user!
      raise SecurityError unless current_user.try(:admin?)
    end
    

    and rescue from that exception in ApplicationController (or you can actually redirect inside the authenticate_admin_user! method)

    rescue_from SecurityError do |exception|
      redirect_to root_url
    end
    

    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:

    config.current_user_method = :current_user
    

    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_for method in the controller

    # path for redirection after user sign_in, depending on user role
    def after_sign_in_path_for(user)
      user.admin? ? admin_dashboard_path : root_path 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to have a Stored Procedure that can only be
I have a group of checkboxes that I only want to allow a set
What would I do if I want to have a generic method that only
My screenshot http://dl.getdropbox.com/u/240752/stars.gif I want to have it so that only the text is
I have an appender that I only want the first X characters (for this
I have some text/images that I only want to display in the normal state
what is the code if you want that only number should be inputted in
I want to create a file that only resides in memory... In looking through
I want to create a sort of light/thick box that only acts on a
I want to make a generic class that accepts only serializable classes, can it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.