ActiveAdmin is great framework for managing website administration interfaces. It allows us to list records of a table, filter them, sort them and also support exporting them in CSV, XML or JSON. By default, records that are being displayed are exported. For example, say we have a products table where each product is distinguished by their type. We can apply a filter to list all electronics products. Clicking on CSV link below the list will export all electronics products only.

But sometimes...

Read complete blog post

Active Admin is a great plugin that helps us to get administration functions with elegant and simple interface up and live quickly without much of a hassle or efforts. One can also make use of various customisations as per their need with very little effort.

In this article, I will be explaining how we can add custom search bar in Active Admin. Adding custom search bar is not as easy and straight forward as other Active Admin customisations. I will be making use of jQuery to do this.

Here, I...

Read complete blog post

How do we customise Titlebar in ActiveAdmin show view? For example, in the attached screenshot, I have breadcrumb as Admin / Orders / Order #11834 in my show view. Instead of that I want to customise it and display it just as "Admin / Orders / Order# 43872378123 & Transaction# MwlDdTc3RW" or just "Admin / Orders / Transaction# MwlDdTc3RW".

Its fairly easy,

In app/admin/order.rb

show title: proc{ |order|
 order.transaction_number.present? ? 
 "Transaction#...

Read complete blog post

I was working on ActiveAdmin views and as we are using html editor for some of our text fields so we wanted to make sure when we are showing that html content in the application. It should be readable and without html tags.

To do that generally it is mentioned to use a block for the field and use .html_safe method. However I did not like this approach, as we have too many fields where I have to call html_safe method and I was not keen to write block for each fields. I know :) I am lazy in...

Read complete blog post

Recently we have used WebUI-Popover plugin in Active Admin. It is a lightWeight popover plugin with jquery.

  • It can be use with bootstrap, but bootstrap is not necessary!
  • Browser compatibility for this plugin is ie8+,Chrome,Safari,Firefox,Opera.
  • We need jquery1.7.1+ for this.

Steps For adding WebUI-Popover are:

1) Download from https://codeload.github.com/sandywalker/webui-popover/zip/1.1.2

2) Extract zip folder go into src folder copy jquery.webui-popover.css this file and paste in...

Read complete blog post

In our current app, there was a requirement to have a nice editor which will provide the basic functionalities like bold,italic and also image upload. We decided to use redactor-rails gem Github-Documentation-Link(Github Doc) .

So i took following steps:

  • In Gemfile i included:
gem 'redactor-rails'
  • Then for image uploading and storing i included two more gems as:
gem 'carrierwave'
gem 'mini_magik'
  • Bundle it.
rails generate redactor:install
rails generate redactor:config
  • In...

Read complete blog post

ActiveSkin gem provides an easy way to customize Active Admin CSS depending upon your website's color scheme in just few minutes.

Steps:

1/ Add to your Gemfile:

gem 'active_skin'

2/ Run:

bundle install

3/ Add to active_admin.css.scss:

//Add the Website's logo. This is displayed on the top-left corner of the page.
$skinLogo: url("logo.png") no-repeat 0 0;

//This color is applied to buttons, drop-down lists etc. in the AA UI
$skinActiveColor:...

Read complete blog post

activeadmin-axlsx gem

activeadmin-axlsx gem is very useful to download or export excel records from active admin.

It provides "XLSX" links to download Active Admin resources.

We can use this gem by include this line in gem file:

gem 'activeadmin-axlsx'

then run:

bundle install

Now all resources of active admin index page include a 'XLSX' link.

There is some example to customize 'activeadmin-axlsx'.

1) Remove unnecessary column:

#app/admin/orders.rb

ActiveAdmin.register Order...

Read complete blog post

In ActiveAdmin, if your resource model is deriving some data from other models, using some kind of relationship(has_one or has_many).

In this scenarios where you want to search and filter the resource based on the data in its related table, you can follow below:

Suppose you have a model School, and a model Student, now you want to search or filter students based on the school name.

We can filter using join(:schools).where("schools.name like") or say an In Query which is inefficient.

Either...

Read complete blog post