but this route has a draw back, I can't access anymore to given parts of my app as 'admin/content' or 'admin/category' because these urls match my content route.
So my question is, how can I skip this route when my url begins with 'admin' ?
try putting it lower in the list. routes match the first one found in
the list, so if ':category/:content' is above 'admin/content' then
it's always going to match and 'admin/content' will never be seen.
you shouldn't have to create a route for each module in your admin area
map.admin 'admin/:action', :controller => 'admin'
should be enough. put it between map.home and map.content routes
so when rails sees anything beginning with admin it will route to the
admin controller and whatever is in the :action param will map to a
method in the controller
unfortunately when using controllers that way, I don't think there is
any way to setup routes any differently. perhaps someone else on the
list has some additional insight.
one potential problem would be if someone tried to access an admin
route that did not exist, such as /admin/whatever'. it would not
match any of your defined admin routes and would then pass to
':category/:content' which would be routed to 'home/show'...something
to watch for. i think one additional route to catch anything else.
'admin/:missing' might be needed and could be routed to a 404 page or something.
keep in mind that you're not going to be editing routes much. so while
you might consider it ugly, it's only in the routes.rb file and not
the rest of your code.
you might want to go one extra step and use named routes as that will
make the rest of your code a bit prettier.