Hello, Let's call my first controller "admin" It's my main administration controller My second controller is called "admin/category" I use this controller to manage my categories on the admin side. Now if I enter the following url "http://localhost:3000/admin/category/list" I encounter an error because rails tries to use the default route map.connect ':controller/:action/:id' and tries to match with the "admin" controller and the action "category" and the id "list". I think this behaviour is not normal because in the "admin" controller there is no "category" action. I'd like rails to find by itself the controller "admin/category" and call the "list" action. In the present case i'm forced to define a new route map.connect 'admin/category/:action/:id', :controller => 'admin/category' If i had no "admin" controller but only a "admin/category" controller it works with default route. I'm i right ? or is there some configuration trick i didn't noticed ?
on 2005-12-13 20:37
on 2005-12-13 21:18
One way to get around this is to do the following. Keep your category controller as it is, but make the 'admin' controller into something like 'admin/main' or the like. Then, in your routes add something like: map.connect "/admin/", :controller => "admin/main", :action => "index" which will allow you just type in /admin/ and get to the index. I have my site set up this way, and it works well because I really only use the index action on this controller anyways. Hope this helps! -Nick
on 2005-12-13 21:21
On 13-dec-2005, at 19:37, gros gros wrote: > I encounter an error because rails tries to use the default route > In the present case i'm forced to define a new route > map.connect 'admin/category/:action/:id', :controller => > 'admin/category' > > If i had no "admin" controller but only a "admin/category" > controller it > works with default route. > > I'm i right ? or is there some configuration trick i didn't noticed ? I guess there is. If you put controllers in subdirectories you have to namespace them. '/admin' :controller=>'admin/main' for Admin::MainController and further on it will pick them automatically Admin::CategoriesController and so on and so forth
on 2005-12-14 10:23
Ok thank you all, so i'll create something like 'admin/main' :/