Where do admin-level views/actions belong?

I often end up with a case were there are admin versions of views. For example I need to allow a user to view a list of her orders so I create orders/index.html.erb. Then later I realize I need a different page for the site owner/admin to view all the orders in the system: orders/admin_index.html.erb with a corresponding admin_index action on the controller? In many cases the other common actions such as show, update etc might need an admin version too. It always gets messy, especially route and authorization declarations e.g.:
get 'admin/orders/index', to:"orders#admin_index"

Just wondering if there’s a common approach here. Should I consider making an admin version of the controller AdminOrdersController and keeping the admin views at: orders/admin/index.html.erb? Is it bad practice to have admin-only actions and user-actions mixed in the same controller?

Any thoughts very much appreciated. (On Monday of course!) Have a good weekend everybody.

I’ve been down the path of custom admin views and authorization conditionals littered throughout my application in the past. I never found an elegant solution for it, but switching to ActiveAdmin made my life a lot easier.

I also helped for things like user demos and screenshots, as I don’t have to log into a separate account or have the user see links and options that they themselves won’t see.

I create seperate admin-folders under ‘controllers’ and ‘views’

then in my routes file I create a namespace ‘admin’ for the admin pages:

namespace :admin do
  resources :news_articles
  resources :members
  resources :publications
  resources :stakeholders

you can watch an example repo here:

hope this helps,


I also namespace my admin controllers like Anthony does.


Something like this, for example: https://github.com/thoughtbot/upcase/blob/master/app/controllers/admin/masquerades_controller.rb

There’s not a corresponding controller on the user side (a user can’t masquerade), but I think you’ll see the general idea.

Thanks everyone for the suggestions. Cool to see a similar/identical suggestions and thanks for the links to examples. Great to look thru these repos and get some new ideas. Thanks again!