Rails routing: namespace nested in a scope

namespaces, ruby-on-rails, scope, url-routing

Solution

Try to add this in your application controller:

def default_url_options(options={})
  {:locale => I18n.locale}
end

It worked for me, I suggest you to read the sections of the I18n guide where to explain how to set the locale from the URL params.

PS: Welcome to StackOverflow ;)

Problem

With Rails 3.2 I have the following in config/routes.rb ``` scope "/:locale" do resource :users, :only => [:new, :create] namespace :admin do resources :specifications end end ``` Users routes works as expected, specifications routes works except index. With a GET call to "/en/admin/specifications" the following error is returned: ``` No route matches {:action=>"show", :controller=>"admin/specifications", :locale=>#<Specification id: 1, name: "Check-in", created_at: "2012-04-28 12:10:29", updated_at: "2012-04-28 12:10:29">} ``` What am I doing wrong ?

Original source