code

How To Create An Admin Panel In Ruby on Rails

Yashu Mittal

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:

Cons:

RailsAdmin

Pros:

Cons:

Administrate

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 production applications.

I’d love to tell you: “use RailsAdmin!” or: “use ActiveAdmin”, but unfortunately, I can’t. The tool has to be adjusted to the needs of the client, so if your client has very specific demands for admin panel (which is strange, because it’s not a CMS, it’s a panel for administrate data… but whatever), for example: “This should be on the top left, then next to it should be that, then we need a vertical line and a picture of my cat, and also I’d like to integrate it with Slack in real time”, then you probably should choose ActiveAdmin. It’s much easier to operate, has 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 data, allows to create 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. 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 to be written, all new models that should appear in the admin panel can be either added to the whitelist or automatically. In effect, such tasks as “add users to 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 mostly spend time on things that are not implemented by default, that is: 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, because you know it doesn’t provide any other additional value than “you don’t have to go to posts section, create a post, then move to comments section and create a comment for that post”, you can do that in one place. In my opinion that’s the biggest benefit of RailsAdmin - you don’t have to do that basic stuff all the time.

Make your business online with a website

Response to “How To Create An Admin Panel In Ruby on Rails”

Stay current

Sign up for our newsletter, and we'll send you news and tutorials on business, growth, web design, coding and more!