How to Create an Admin Panel in Rails

Photo of Marek Mikołajczyk

Marek Mikołajczyk

Updated Mar 6, 2023 • 5 min read
Ruby_vs_Ruby_on_Rails_projects

I did some research on admin panel tools, that is RailsAdmin, ActiveAdmin and Administrate. Every tool did its job perfectly, but there were some major differences.

ActiveAdmin

Pros:

  • has its own DSL;

  • application progress is pretty steady with ActiveAdmin, which means that the cost of adding a new feature will most likely be the same at any point;

  • recommended by Netguru as a basic admin panel tool.

Cons:
  • requires you to do some reading before you are able to create something complex;

  • has a slow startup comparing to the two other tools;

  • doesn’t support nested relations by default - you have to write it on your own;

RailsAdmin

Pros:

  • has its own DSL;

  • easy to start (after the setup, there’s almost no work required to create full administration panel);

  • can use previously created Fields, Actions, Sections and so on, so if you need graphical representation of your data, there’s a big chance that someone has already done it and you can use it in your app;

  • provide nested relations by default, so you don’t waste time on implementing that.
Cons:
  • much harder to learn and to do more complex stuff;

  • harder to create things that are not included in base gem and modify views.

Administrate

  • doesn’t have any DSL;

  • you can override anything without doing hacks, controllers and views are available for you to override;

  • easy setup;

  • easy everything;

  • doesn’t provide nested relations by default;

  • still pre 1.0, not ready for production.

Administrate looks really promising, but at the time when I’m writing this, it’s still pre 1.0 and may change substantially, so it’s not recommended to use in the production apps.

I’d love to tell you: “use RailsAdmin!” or: “use ActiveAdmin” but, unfortunately, I can’t. The tool must be adjusted to the needs of the client, so if your client has very specific demands for the admin panel (which is strange, because it’s not a CMS; it’s a panel for administrative data... but whatever), for example: “This should be on the top left. Then, next to it should be that. Also, we need a vertical line and a picture of my cat. On top of that, I’d like to integrate it with Slack in real time”... then you should probably choose ActiveAdmin. It’s much easier to operate, it has a pretty clear syntax and there’s almost no magic happening. Prepare yourself to write nested forms.

On the other hand, if your client only wants an admin panel that works, shows the data, allows creating new data, and the styling is not important (even though, in my opinion, the standard RailsAdmin looks much better than ActiveAdmin), then you can be 99% sure that RailsAdmin is your choice. The initial setup is really easy. After that, you just have to add some kind of authentication and that’s all. You've finished your admin panel, no further work required, no nested forms needed, all new models that should appear in the admin panel can be either added to the whitelist or automatically. In effect, tasks such as “add users to the admin panel” will most likely take less than 5 minutes.

I won’t talk much about Administrate, because it’s not ready yet, but I think that in a year or so this will be the basic admin panel tool, used by every application, just like Devise right now.

You’ve probably noticed that I wrote about nested relations a couple of times. That’s because admin panels mostly don’t have any special logic and are pretty standard, so you’ll most probably spend time on things that are not implemented by default, i.e. nested relations. You’ll have to display them in the show action. You’ll have to create forms for them in the edit/new action. You’ll have to show some kind of a summary of them in index actions. That’s the most annoying part of maintaining an admin panel, as you know it doesn’t provide any other additional value than “you don’t have to go to the posts section, create a post, then move to the comments section and create a comment for that post” - you can do that in one place. In my opinion, the biggest benefit of RailsAdmin is that you don't have to do that basic stuff all the time.

Tags

Photo of Marek Mikołajczyk

More posts by this author

Marek Mikołajczyk

Marek started at Netguru as a great Ruby intern and stayed for good. He’s been interested in...
Lost with AI?  Get the most important news weekly, straight to your inbox, curated by our CEO  Subscribe to AI'm Informed

We're Netguru

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency.

Let's talk business