Optimize activeadmin (ruby gem) dropdown resulting in slow page loads

Hi all, Welcome to another mystery solving.

This post will help you optimize your page loads in activeadmin.

If you don’t already know what activeadmin gem is, then refer here.


While using activeadmin, I was facing performance issue on page loads. It was extremely slow. It was also resulting in memory overshooting.

If you are reading this post, then you probably encountered the above stated problem or maybe you just like to read and stay updated ;P

How did I debug the issue?

I started checking with network calls and db queries happening behind the scenes by looking at the logs (That’s why logging is very important).
On looking at the network call using browser console, I figured out somehow the page size that was getting loaded was significantly large [ For the stated observation, issue might have been something like loading of huge amount of data and since table was getting created and data was paginated, this could not have been the issue for memory overshooting in my case but this is worth a check. If your data is not paginated, then do that as your first solution ].
While checking all the queries the one thing that was already taken care was the problem on N+1 queries which can be solved by using includes for the associations.
If you look closely through the queries that were running, I came across a query which was returning the whole result set for the table with huge number of records. That being said, the issue was with the filter that was present on the list page which was actually trying to fit all those records into a dropdown (Page rendering can be a pain). [ Finally founded the root cause of the problem in my scenario ].


Since, it was a gem (activeadmin) I was dealing with, the quick solution might be to use another gem to solve similar problem. Actually this problem was quite analogous to the one that I encountered when I was working with django-admin (built in ready to use admin application with django – python based web framework).

One of the solution was to not use the dropdown for loading associations, better to use a searchable ajax enabled select option. Fortunately, I founded a gem that was doing the exact same thing. The gem was activeadmin-searchable_select. It has pretty straight forward documentation that you can follow to meet your ends. This basically extends activeadmin features by certain extent by using select2 (searchable select) and provide some more modifications on form and filters.

I hope this post have been helpful in debugging your performance issue for activeadmin and also providing the solution.

See you all in next post. Au Revoir!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.