Take the 2-minute tour ×

I'm wondering what's Rails approach when it comes to creating a full-fledged admin control panel. And by full-fledged I mean a real control panel that could be used on a professional level, not personal/internal scaffolding.

I don't believe its stored in the same folder as the user interface as it's shown in the blog screencast or in Getting Started with Rails tutorial!

I'm certain the same model will be used everywhere but what about the views?

Please explain in details. I don't want to use my PHP mentality when starting my first real project in Rails.


share|improve this question
What do you want your admin control panel to do? –  Ant Jun 6 '11 at 8:57
Everything. Let's assume it's a news site with editors who can login to manage the stories, create categories, add new editors, etc etc. –  emurad Jun 6 '11 at 12:25
add comment

3 Answers

up vote 2 down vote accepted

As hinted at by the previous answers namespacing is useful to keep admin functionality neatly separated from other user functionality, for example:

# In your routes

namespace :admin do
  resources :stories
  resources :editors

Then you'd put all your admin controllers in an 'admin' subfolder and always require an admin to access them:

# app > controllers > admin > stories_controller.rb

class Admin::StoriesController < ApplicationController

  before_filter :authenticate_admin!   # assuming you're using devise

  def index


The advantage of this is you only have to check for admin in one place (the before_filter of an admin controller) rather than having to put conditionals everywhere in your normal controllers / views.

share|improve this answer
That sounds great. Is this doable in Rails out of the box or additional gems are needed? –  emurad Jun 6 '11 at 12:40
@emurad It's out of the box functionality, apart from Devise for authentication, that's a gem. –  Ant Jun 6 '11 at 13:05
Just as an addition to this, what i normally do is have class AdminController in my regular controllers folder, which has a before_filter method "require_admin" or similar, and have a subfolder in controllers called admin, which contains the controllers like class Admin::StoriesController << AdminController. That way all of your admin controllers are admin-only, and you can add any other shared functionality into AdminController. –  Max Williams Jun 6 '11 at 13:11
add comment

here you can find a list of rails plugins/engines to manage admin interfaces:


I've used a bunch of them (typus and rails_admin), not bad at all.

also check the recent released ActiveAdmin


share|improve this answer
add comment

It depends on the nature of your application, but there's nothing wrong with having the admin functions in the same view as the user; Just test your permission role before showing certain part of the display.

If you really need an admin only interface, you could namespace some controllers and views. There are other posts that deal with how to do this, such as The Rails Way - Namespaces

share|improve this answer
Let's take a REAL application like 37signals Basecamp. Do you think their admin control panel (where they manage users, do the billing, etc) lives beside the user interface in term of controllers and views? –  emurad Jun 6 '11 at 12:28
add comment

Your Answer


