# Nested Controllers - Development vs. Production mode

**URL:** <https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410>\
**Category:** Rails\
**Created:** [August 30, 2007, 8:58pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410 "2007-08-30T20:58:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [August 30, 2007, 8:58pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/1 "2007-08-30T20:58:35Z")

</div>

Hello,

I’m still relatively new to Ruby/Rails and am in the middle of my first  
deployment to production. I’ve encountered an odd difference between  
development and production mode, and I’m not sure what the cause is.

My site is set up under two main controllers, “secure” and “admin”.  
Each of these has several sub-controllers, for example: “admin/users”,  
“admin/announcements”, etc.

On my development site, the links between these controllers all work  
fine. However, when I moved to production, the links no longer work  
unless I pass along an :id or other parameter through the querystring  
params.

In other words, this results in a page not found error:

\<%= link\_to ‘Announcements’, {:controller =\> ‘admin/announcements’,  
:action =\> ‘index’} %\>

And this works:

\<%= link\_to ‘Announcements’, {:controller =\> ‘admin/announcements’,  
:action =\> ‘index’, :id =\> ‘0’} %\>

And both work in my development environment.

Without the parameters, I get the following error in my production.log  
file:

Processing AdminController#announcements (for xxx at xxx) [GET]  
Session ID: xxx  
Parameters: {“action”=\>“announcements”, “controller”=\>“admin”}

ActionController::UnknownAction (No action responded to announcements):

Why is the production box looking for a method within admin whereas the  
development box is correctly finding the controller? Is this a server  
setting somewhere? Again, it’s the same code in both locations…

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [August 30, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/2 "2007-08-30T22:45:52Z")

</div>

On Aug 30, 1:58 pm, Brian S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On my development site, the links between these controllers all work  
> fine. However, when I moved to production, the links no longer work  
> unless I pass along an :id or other parameter through the querystring  
> params.

Perhaps you’ve modified routes.rb without restarting the server in  
production?

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [August 31, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/3 "2007-08-31T15:10:33Z")

</div>

Jeff C. wrote:

> Perhaps you’ve modified routes.rb without restarting the server in  
> production?

I thought of that as well, but I verified that it is the same routes.rb  
file in both locations and I’ve restarted the server since then. I’m  
still running into this issue.

I don’t have anything in my routes.rb file specific to the nested  
controllers… could this be the problem? The uncommented lines in my  
routes file are as follows:

ActionController::Routing::Routes.draw do |map|

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

end

The login controller handles user logins, so I redirect users there when  
they first reach the site.

Any other thoughts?

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [August 31, 2007, 10:14pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/4 "2007-08-31T22:14:35Z")

</div>

On Aug 31, 8:10 am, Brian S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I don’t have anything in my routes.rb file specific to the nested  
> controllers… could this be the problem? The uncommented lines in my  
> routes file are as follows:

Ah, sorry I thought you were using restful controllers with  
map.resources. I think yes, the problem is that admin/users (for  
example) is being matched incorrectly by the catch-all case. Try  
this:

map.connect ‘admin/users/:action/:id’, :controller =\> ‘admin/users’

and place it above all of the others. If this helps, you can do the  
same for the other subcontrollers too. Once working, I think you can  
simplify all of the admin routes by using path\_prefix instead. But  
try them one at a time first, that’s how I’m able to understand what’s  
going on first.

And let me know if this helps or not. 🙂

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

[essentialrails.com](http://essentialrails.com)

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [September 4, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/5 "2007-09-04T20:25:20Z")

</div>

> map.connect ‘admin/users/:action/:id’, :controller =\> ‘admin/users’

This worked. Thanks for your help!

I’m still not clear on why this why this was only needed once I deployed  
to my production environment (a shared host). I suppose it has  
something to do with the way in which my hosting provider has the server  
configured. Regardless, this did the trick.

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [September 4, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/nested-controllers-development-vs-production-mode/113410/6 "2007-09-04T23:28:38Z")

</div>

On Sep 4, 1:25 pm, Brian S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > map.connect ‘admin/users/:action/:id’, :controller =\> ‘admin/users’
> 
> This worked. Thanks for your help!

Awesome! Glad to help.

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

[essentialrails.com](http://essentialrails.com)
