# Nested Controllers

**URL:** <https://www.ruby-forum.com/t/nested-controllers/79864>\
**Category:** Rails\
**Created:** [December 20, 2006, 12:02am UTC](https://www.ruby-forum.com/t/nested-controllers/79864 "2006-12-20T00:02:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 12:02am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/1 "2006-12-20T00:02:28Z")

</div>

I’m currently developing a project in which I want to have an  
administration section. The development server is running with Bluehost  
([bluehost.com](http://bluehost.com)) on a shared server plan (since I am not always developing  
on one machine, and need to have mobility in development).

I have created a number of controllers as nested controllers. For  
example:

[http://domain.com/acumen/](http://domain.com/acumen/)  
[http://domain.com/acumen/users/](http://domain.com/acumen/users/)  
[http://domain.com/acumen/tasklists/](http://domain.com/acumen/tasklists/)  
[http://domain.com/acumen/projects/](http://domain.com/acumen/projects/)  
[http://domain.com/acumen/tasks/](http://domain.com/acumen/tasks/)  
etc.

The folder structure in the /controllers/ folder mirrors what you see  
there. As far as I can tell, this should work perfectly - I’ve read a  
number of tutorials that do this just as I have done this, and they all  
seem to work. Unfortunately, it is not working.

Whenever I try to access one of the controllers underneath the acumen  
controller, I get the following error:

Routing Error

Recognition failed for “/acumen/tasks/”

My routes.rb file has the following routes in the following order. I  
have also shown a few things that I have tried to resolve the routing  
problems, but they are commented out, as you can see, and should not  
affect right now:

ActionController::Routing::Routes.draw do |map|  
map.connect ‘’, :controller =\> “home”

map.connect ‘:controller/service.wsdl’, :action =\> ‘wsdl’

# Routes to our acumen controller?

#map.connect ‘acumen/:controller/:action/:id’

#map.connect ‘acumen/projects/:action’, :controller =\> ‘projects’

map.connect ‘:controller/:action/:id’  
end

Is this perhaps a problem with the Bluehost hosting environment?

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 12:20am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/2 "2006-12-20T00:20:48Z")

</div>

Bryan C. wrote:

> The folder structure in the /controllers/ folder mirrors what you see  
> there.

Can you be more explicit - just so I know exactly how your  
/app/controllers folder looks first?

Is it:

/app/controllers/acumen/  
/app/controllers/acumen/users/  
/app/controllers/acumen/tasklists/  
/app/controllers/acumen/projects/  
/app/controllers/acumen/tasks/

or

/app/controllers/  
/app/controllers/users/  
/app/controllers/tasklists/  
/app/controllers/projects/  
/app/controllers/tasks/

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 12:23am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/3 "2006-12-20T00:23:42Z")

</div>

It is:

> /app/controllers/acumen/  
> /app/controllers/acumen/users/  
> /app/controllers/acumen/tasklists/  
> /app/controllers/acumen/projects/  
> /app/controllers/acumen/tasks/

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 12:32am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/4 "2006-12-20T00:32:05Z")

</div>

Ok well assuming you are wanting to connect to a controller in the  
acumem folder, say ‘TestController’, i.e.

/app/controllers/acumen/test\_controller.rb

Then you need this in the routes.rb

map.connect ‘acumen/:controller/:action/:id’

No this should work is you go to URL:

/acumen/test

It’s the controller names that matter, not the folders. Rails doesn’t  
care which folders you put your controllers in beneath the  
/app/controllers folder (they are all in the same namespace).

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 2:59am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/5 "2006-12-20T02:59:11Z")

</div>

I activated that route just below the WSDL route. Currently I’m  
receiving this error:

Unknown action

No action responded to projects

This leads me to think that it is reading it as the acumen controller,  
action projects?

Note: You mentioned namespace. My sub-controllers are declared like  
this:

class Acumen::ProjectsController \< AcumenAreaController

Where I have substituted AcumenArea Controller for  
ApplicationController, so that my layout and login requirements are  
consolidated in a single place. AcumenAreaController looks like this:

class AcumenAreaController \< ApplicationController  
before\_filter :login\_required  
layout “site-layout”  
end

> map.connect ‘acumen/:controller/:action/:id’

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 8:58am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/6 "2006-12-20T08:58:53Z")

</div>

On 12/19/06, Bryan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Recognition failed for “/acumen/tasks/”  
> map.connect ‘:controller/service.wsdl’, :action =\> ‘wsdl’
> 
> # Routes to our acumen controller?
> 
> #map.connect ‘acumen/:controller/:action/:id’
> 
> #map.connect ‘acumen/projects/:action’, :controller =\> ‘projects’
> 
> map.connect ‘:controller/:action/:id’  
> end
> 
> Is this perhaps a problem with the Bluehost hosting environment?

All you need is the default route and a controller like

# app/controllers/acument/tasks\_controller.rb

class Acumen::TasksController \< ApplicationController  
…  
end

jeremy

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 8:16am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/7 "2006-12-20T08:16:50Z")

</div>

On Dec 19, 8:59 pm, Bryan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Note: You mentioned namespace. My sub-controllers are declared like  
> layout “site-layout”  
> end
> 
> > map.connect ‘acumen/:controller/:action/:id’–  
> > Posted viahttp://www.ruby-forum.com/.

Is this Rails Weenie thread helpful?

[http://rails.techno-weenie.net/forums/1/topics/544](http://rails.techno-weenie.net/forums/1/topics/544)

Best,

-r

–  
Ryan R.  
[http://raaum.org](http://raaum.org)  
[http://rails.raaum.org](http://rails.raaum.org) – Rails docs  
[http://locomotive.raaum.org](http://locomotive.raaum.org) – Self contained Rails for Mac OS X

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [December 20, 2006, 9:32am UTC](https://www.ruby-forum.com/t/nested-controllers/79864/8 "2006-12-20T09:32:20Z")

</div>

Just an idea… try it with all the controllers subclassing the  
ApplicationController instead and see if that works, i.e.

class Acumen::ProjectsController \< ApplicationController

If so, then using the module name ‘Acumen’ is causing the problem. Just  
use a different name from ‘Acumen’ in case it conflicts with the path  
/acumen/
