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 ? -- Posted via http://www.ruby-forum.com/.
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 12/13/05, gros gros <thomas.gros-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 ? > > > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 13-dec-2005, at 19:37, gros gros wrote:> 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 ?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