Nested Controllers

I’m currently developing a project in which I want to have an
administration section. The development server is running with Bluehost
(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/users/
http://domain.com/acumen/tasklists/
http://domain.com/acumen/projects/
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?

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/

It is:

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

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).

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’

On 12/19/06, Bryan C. [email protected] 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

On Dec 19, 8:59 pm, Bryan C. [email protected] 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

Best,

-r


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

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/