Jump to content

The ultimate community for Ruby on Rails developers.


Active Admin

ruby on rails active admin

  • Please log in to reply
No replies to this topic

#1 rubyonrailsdevelopment



  • Members
  • 23 posts
  • LocationUS California

Posted 16 November 2016 - 09:55 AM

Admin section is a common module for most of the applications. For Rails applications we have a gem called Active Admin. That can be used to create application from scratch to admin interfaces with little effort.

Its a framework where all the admin tasks can be managed. It creates the beautiful admin interface that gives you access to manage the data and it can be customized easily.

How to install and setup?

First I will be creating three modules for my Rails 5 application.

Artist, Producer and Movie

has_many :movies
has_many :movies
belongs_to :artist
belongs_to :producer

Lets add activeadmin to the gemfile and do bundle install.

gem 'devise'
gem 'activeadmin', github: 'activeadmin'
bundle install

There are some dependencies you need to add for Rails 5. Add below gem to the gemfile and do bundle install again.

gem 'inherited_resources', github: 'activeadmin/inherited_resources'

Run the generator to install active admin. It creates all the administrative files under app/admin directory. Device gem used by active admin for authentication.

rails g active_admin:install

Your terminal prompts you some settings need to be configured manually once you ran above command.

ActiveAdmin Authentication

Requires two settings to authenticate and use current user in the application.

To force controller methods to authenticate

config.authentication_method = :authenticate_admin_user!

To access current user from the methods

config.current_user_method = :current_admin_user

Both above settings can be set to false to turn off authentication.

Start the rails server and navigate to the http://localhost:3000/admin. You can login by using following credentials.

Username: admin@example.com
Password: password


The admin dashboard will be displayed once you login successfully. Top menu is showing the list of models registered with active admin. As of now we have only one model AdminUser. Here you can create or edit admin information.

Customizing Views
Here we need to register our models with active admin.

rails generate active_admin:resource Artist
rails generate active_admin:resource Producer
rails generate active_admin:resource Movie

Before that lets add some data to your db.


Know More About Active Admin and its Customization from here: http://www.railscarm...s/active-admin/

Also tagged with one or more of these keywords: ruby on rails, active admin

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users