List of Controllers?

How can I get a list of controllers from within rails?
I cant see any documentation on this anywhere.

Thanks,

Matt

I’m not quite sure what you are asking for here, but wouldn’t looking in apps/controller tell show you all the controllers?

Chris

Im trying to programatically display the list of controllers in my app
(models would also be nice), preferably without a filesystem lookup of
the app directory.

The method

   ActionController::Routing.possible_controllers

performs a file system lookup and will give you a starting point.

If you don't want that approach for whatever reason albeit it is already written, you could try something like

   ApplicationController.subclasses

You'd need to be sure all controller classes have been loaded in that case. Controllers are loaded on-demand, so in production mode you'll need a request for each one (modulus details, hierarchies, etc.). In development mode that approach won't work in general because of const removing (the trick to get autoloading per request), in the general case in development mode only one controller class is known at any given request.

-- fxn

The method

   ActionController::Routing.possible_controllers

performs a file system lookup and will give you a starting point.

If you don't want that approach for whatever reason albeit it is
already written, you could try something like

   ApplicationController.subclasses

You'd need to be sure all controller classes have been loaded in that
case. Controllers are loaded on-demand, so in production mode you'll
need a request for each one (modulus details, hierarchies, etc.). In
development mode that approach won't work in general because of const
removing (the trick to get autoloading per request), in the general
case in development mode only one controller class is known at any
given request.

-- fxn

You are a diamond - just what I was looking for

Thanks,

Matt