Hello. I''m adding an admin section to my site and have configured routing along the following lines: map.connect ''admin/:controller/:action/:id'' The above works fine. However, if I have controller ''A'', it is still accessible from http://mysite.com/A due to the default :controller/:action/:id route. I''d rather not have two URIs mapped to the same page and am wondering if there is a way to exclude a controller from a route or to alter the path to http://mysite.com/admin/A when a user visits http://mysite.com/A. As of now, my only solution is to remove the :controller/:action/:id route, but this means I would have to map routes for every controller I want accessible at my webroot which is kind of a pain and doesn''t seem very rails like. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t know the solution to what you are asking about excluding controllers. I think the namespacing of controllers has been discussed before and some people like it some people don''t. Name your admin controllers Admin::AdminTestController and place them in admin/admin_test_controller.rb script/generate controller Admin::AdminTestController This can then be accessed with admin/admin_test without modifying the stock routes. That should solve your problem if I read your post correctly. I''m assuming you have some sort of authentication too, that could be used to restrict access to the controllers except for admin users. Fredrik On Mar 16, 8:02 am, "thelorax" <adweinst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello. I''m adding an admin section to my site and have configured > routing along the following lines: > > map.connect ''admin/:controller/:action/:id'' > > The above works fine. However, if I have controller ''A'', it is still > accessible fromhttp://mysite.com/Adue to the > default :controller/:action/:id route. I''d rather not have two URIs > mapped to the same page and am wondering if there is a way to exclude > a controller from a route or to alter the path tohttp://mysite.com/admin/A > when a user visitshttp://mysite.com/A. As of now, my only solution > is to remove the :controller/:action/:id route, but this means I would > have to map routes for every controller I want accessible at my > webroot which is kind of a pain and doesn''t seem very rails like. > > Thanks.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thelorax wrote:> The above works fine. However, if I have controller ''A'', it is still > accessible from http://mysite.com/A due to the > default :controller/:action/:id route. I''d rather not have two URIs > mapped to the same page and am wondering if there is a way to exclude > a controller from a route or to alter the path to http://mysite.com/admin/A > when a user visits http://mysite.com/A.you can use the :requirements param of the route, so you can match :controller against a regexp. If the pattern is not matched, then the route will not be recognized for that request regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks. Both the Admin::Controller and the :requirements option look like they might work for me. On Mar 16, 10:10 am, javier ramirez <jrami...-7iWCczGtl7hBDgjK7y7TUQ@public.gmane.org> wrote:> thelorax wrote: > > The above works fine. However, if I have controller ''A'', it is still > > accessible fromhttp://mysite.com/Adue to the > > default :controller/:action/:id route. I''d rather not have two URIs > > mapped to the same page and am wondering if there is a way to exclude > > a controller from a route or to alter the path tohttp://mysite.com/admin/A > > when a user visitshttp://mysite.com/A. > > you can use the :requirements param of the route, so you can match > :controller against a regexp. If the pattern is not matched, then the > route will not be recognized for that request > > regards, > > javier ramirez > > -- > -------- > Estamos de estreno... si necesitas llevar el control de tus gastos visitahttp://www.gastosgem.com!!Es gratis!!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---