Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I optimize active_admin

Last time I got the problem with active_admin. In tables where I have 5000+ rows of data it's work very slowly. How I can optimize it? Maybe somebody know some async load plugins for this module?

like image 437
itdxer Avatar asked Oct 29 '13 10:10

itdxer


People also ask

Why use Active Admin?

Active Admin is a framework for creating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.

What is Admin:: Rails?

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data. 2022. 6,667,536. Stars.


1 Answers

There are a couple things you can do.

By default, Active Admin loads associations as drop-down filters on the index page. If those filters aren't being used, it helps to remove them because they instantiate every record of that model to build the drop-down.

ActiveAdmin.register Post do
  remove_filter :categories
end

If your index page has columns that depend on associated records, it helps to eager-load them.

ActiveAdmin.register Post do
  controller do
    def scoped_collection
      super.includes :author, :publisher
    end
  end
end

This doesn't really apply since you only have 5000 records, but if you get to the point where even a DB COUNT of the table takes a long time, you might want to disable the count in the bottom right of the index page. (this feature was added in 0.6.1)

ActiveAdmin.register Post do
  index pagination_total: false
end
like image 182
seanlinsley Avatar answered Oct 06 '22 11:10

seanlinsley