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

On 6/11/07, Matt [email protected] wrote:


You know you’ve achieved perfection in design, Not when you have nothing
more to add, But when you have nothing more to take away.
– Antoine de Saint-Exupery

On Jun 11, 10:06 pm, “Chris Johnston” [email protected] wrote:

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

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.

On Jun 11, 2007, at 11:50 PM, Matt wrote:

On Jun 11, 10:06 pm, “Chris Johnston” [email protected] wrote:

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs