# How to specify controller '/admin/foo'

**URL:** <https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678>\
**Category:** Rails\
**Created:** [June 5, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678 "2008-06-05T23:21:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 5, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678/1 "2008-06-05T23:21:27Z")

</div>

WeBrick handles the link correctly on development, but apache in  
production does not:

\<%= link\_to “Orders”, :controller =\> ‘/admin/orders’, :action =\> ‘index’  
%\>

The controller lives in ./app/controllers/admin/orders\_controller.rb

From the production log, apache is looking for the “orders” action in  
“./app/controllers/admin\_controller.rb” and not finding it.

– log message on production –

Processing AdminController#orders (for 209.11.127.13 at 2008-06-05  
14:19:19) [GET]  
Session ID: 24e7a44689df1c85a911492e0d581985  
Parameters: {“action”=\>“orders”, “controller”=\>“admin”}

* * *

I expected it to look for the “index” action in the “orders”  
controller.

–  
Anthony E.  
408-656-2473  
[http://anthony.ettinger.name](http://anthony.ettinger.name)

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 6, 2008, 4:05am UTC](https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678/2 "2008-06-06T04:05:42Z")

</div>

Anthony E. wrote:

> WeBrick handles the link correctly on development, but apache in  
> production does not:
> 
> \<%= link\_to “Orders”, :controller =\> ‘/admin/orders’, :action =\> ‘index’ %\>
> 
> The controller lives in ./app/controllers/admin/orders\_controller.rb

I suspect you either can’t or don’t want to put sub-folders among the  
controllers.

Just write an app/controllers/orders\_controller.rb

if you need the URI /admin/orders/index, then write a named route into  
your  
routes.rb file.

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 6, 2008, 4:50am UTC](https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678/3 "2008-06-06T04:50:19Z")

</div>

\<%= link\_to “Orders”, :controller =\> ‘admin/orders’, :action =\> ‘index’  
%\>  
Try this

---

<div class="post-metadata">

**Author:** ![chovy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@chovy](https://www.ruby-forum.com/u/chovy)\
**Post date:** [June 6, 2008, 5:07am UTC](https://www.ruby-forum.com/t/how-to-specify-controller-admin-foo/139678/4 "2008-06-06T05:07:08Z")

</div>

have you tried " :controller =\> ‘admin/orders’ "?

While it is possible to nest your controllers, I have found that this  
leads to more trouble than it is worth.

Have you considered having your orders controller at the top level,  
and simply having some form of security?

Also, if the above does not work–are you using default routes, or  
something else? If something else can we have a peek?
