Lessons on Rails: Implementing Administrate

For the past couple weeks I’ve been building Cast Party, and today I implemented an admin dashboard using the Administrate gem. It was a pretty simple process, but I included a few customizations that I didn’t find documented anywhere else.

I started with the Getting Started guide on Administrate’s site. It was well written and got me most of the way. If you want to customize the views at all, you have to generate the views separately, so I recommend reading that guide too, before you get in too deep.

The first thing I had to change was the find_resources method, because I use the Friendly IDs gem for my Person, Show, and Episode models. It was an easy change, and they provided comments in the controllers to help.

Next I wanted to include show images on the Show Index page. To do this I edited the _collection partial and added the highlighted chunk of code below.

Finally, I secured my admin dashboard so that only admin users can access it. To achieve that I added this line to the authenticate_admin method in the admin application_controller:

And that’s all! It was a pretty simple process, but being my first time using Administrate, it still took me a good chunk of the day. If you run into any problems, ping me! I’d love to see what you’re building and see if I can help.