Active Admin - Custom Pages, Views and Actions

Active Admin is a Ruby on Rails plugin to generate Admin console for the application. It has a lots of functionalities implemented out of the box where we just need to integrate it and use it. Most of the time you don’t need to customize the plugin.

But the main Advantage of Active Admin is that you can customize almost all the built-in functionalities. The main functionalities are: Navigation, User Authentication, Scopes, Action Items, Index styles, Filters, Sidebar sections, API and Downloads.

By default Active Admin will generate the pages to CRUD a model when you generate the resource file for the model using rails generator:

    $> rails generate active_admin:resource [MyModelName]


Integrating FriendlyID, Inherited Reource and Active Admin

For my latest spare time project Kazhakkoottam I had to integrate friendly id with the app. But the application was already integrated and running with Inherited Resource and Active Admin. So while integrating with friendly id I have faced some issues.

So why we need to use friendly id?
FriendlyId is used to implement pretty URL's, so that it will be SEO friendly and can be identified easily. Instead of id's you can configure name or title field as the slug. For example is the friendly id for


Active Admin tips and tricks

For my current project I had to setup Admin console. I used Active Admin for that purpose. It is very easy to setup an Admin console. And they have a very good documentation. But if you want make some customization you have to spent some time digging for solution. Following are some customization I made to improve the Admin console:


If you are using select box for showing association in form page or filters, it will show the object string if there is no attribute 'name' for that model. By default the select box will take the name attribute of the model as the values. So you have to use member_label to specify the attribute you want to show in the select box.
f.input :user, :as => :select, :member_label => :email

Deploying a Rails app to a Sub URI

Recently I was working on a POC application. And I had to deploy that application to show a demo. Since it is a POC app I had to deploy it as a Sub URI of an existing app.

I modified the nginx conf file to set up the sub URI, based on the information from this doc. I have added passenger_base_uri option to the conf, but that was just starting the application from the sub URI. All the URLs in the application is using the base URL instead of the sub URI.

To make all the URLs from the application use the sub URI as the base URL, I had to add a scope in the routes:
SubUriApp::Application.routes.draw do
  my_draw = do
   devise_for :users



Devise with token based authentication for API

Currently I am working on a project which has both API and mobile apps. I had to implement authentication for the API. Since I have to implement the authentication for the non browser clients (iOS, Android) I won't be able to use session based authentication. So I started implementing token based authentication. I am using Devise gem for token based authentication.

Devise is a flexible authentication solution for Rails applications. If you search in ruby tool box you will see that Devise is the most popular rails authentication plugin. Devise supports token based authentication too. Read More...