I'm working on a Rails 3.1 app and I'd like to set specific routes for the different languages the app is going to support.
/es/countries
/de/countries
…
For the default language ('en'), I don't want the locale to be displayed in the url.
/countries
Here is the route definition I've set.
scope "(:locale)", :locale => /es|de/ do
resources :countries
end
It works great, until I try to use a path helper with 'en' as the locale.
In the console :
app.countries_path(:locale => 'fr')
=> "/fr/countries"
app.countries_path(:locale => 'en')
=> "/countries?locale=en"
I don't want the "?locale=en".
Is there a way to tell rails that with an 'en' locale, the locale param should not be added to the url?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…