Dealing with multiple root paths and scopes in Rails

Viewed 5588

We have the following routes setup:

MyApp::Application.routes.draw do
  scope "/:locale" do    
    ...other routes
    root :to => 'home#index'
  end
  root :to => 'application#detect_language'
end

Which gives us this:

root      /:locale(.:format)    home#index
root      /                     application#detect_language

which is fine.

However, when we want to generate a route with the locale we hitting trouble:

root_path generates / which is correct.

root_path(:locale => :en) generates /?locale=en which is undesirable - we want /en

So, question is, is this possible and how so?

1 Answers
Related