Daniel wrote:> I have this in my routes.rb:
>
> ...
> map.connect ":action/:id", :controller =>
"default_controller"
> ..
>
>
> It worked nicely, until I added a second controller to my project. The
> new (second) controller is "Admin".
>
> The problem is I cant reach the actions in the second controller.
>
> http://mysite.com/some_action is routed to some_action in
> default_controller. That is how I want it to be. But how do I reach
> admin_action in the Admin controller? This doesnt work, for obvious
> reasons:
>
> http://mysite.com/admin/some_action
>
> it gets routed to the undefined action admin in default_controller with
> id some_action.
>
> How can I correct this so that
>
> http://mysite.com/some_action is routed to to
> default_controller/some_action and
> http://mysite.com/admin/admin_action is routed to
> admin_controller/admin_action
Routes are processed in the order they''re given in routes.rb, so if you
want to trap the admin controller, give it a route BEFORE the one
definining "
/:action'', :controller =>
''default_controller''" etc.
Above that one, put:
map.connect ''/admin/:action'', :controller =>
''admin''
Put the most specific entries first, and the most general ones at the
bottom. That way you can trap the special cases before they''re
resolved
by the general default case.
Jeff
--
Posted via http://www.ruby-forum.com/.