Rails routing: namespace nested in scope

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 route works, as expected, specification routes other than the index. When GET is called in "/ en / admin / specification", 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?

+3
source share
1 answer

Try adding this to your application controller:

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

This worked for me, I suggest you read the sections of the I18n manual where to explain how to set the locale from the URL parameters .

PS: Welcome to StackOverflow;)

+4
source

All Articles