# List of Controllers?

**URL:** <https://www.ruby-forum.com/t/list-of-controllers/106551>\
**Category:** Rails\
**Created:** [June 11, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/list-of-controllers/106551 "2007-06-11T21:27:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [June 11, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/list-of-controllers/106551/1 "2007-06-11T21:27:24Z")

</div>

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

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [June 11, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/list-of-controllers/106551/2 "2007-06-11T23:06:49Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
[www.fuzzylizard.com](http://www.fuzzylizard.com)

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

---

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [June 11, 2007, 11:51pm UTC](https://www.ruby-forum.com/t/list-of-controllers/106551/3 "2007-06-11T23:51:55Z")

</div>

On Jun 11, 10:06 pm, “Chris Johnston” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [June 12, 2007, 12:27am UTC](https://www.ruby-forum.com/t/list-of-controllers/106551/4 "2007-06-12T00:27:58Z")

</div>

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

> On Jun 11, 10:06 pm, “Chris Johnston” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a6a055/32.png) [@matt](https://www.ruby-forum.com/u/matt)\
**Post date:** [June 12, 2007, 12:36am UTC](https://www.ruby-forum.com/t/list-of-controllers/106551/5 "2007-06-12T00:36:59Z")

</div>

> 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
