I18n routes: missing required keys: [:locale]

1.4k views Asked by At

With Rails 4 and I18n.

When i call path like

conversation_path(locale: :de, 1)

it gives me an error saying

No route matches {:action=>"show", :controller=>"frontend/conversations", :id=>1, :locale=>:de} missing required keys: [:locale]

routes.rb

scope '/:locale' do
  localized do
    scope module: 'frontend' do
      resources :conversations, only: [:index, :show]
    end
  end
end

rake routes gives me

conversation_de GET /:locale/conversations/:id(.:format) frontend/conversations#show {:locale=>"de"}
conversation_en GET /:locale/conversations/:id(.:format) frontend/conversations#show {:locale=>"en"}

am i missing something?

1

There are 1 answers

0
Aleksandr K. On BEST ANSWER

Try to change in routes.rb

scope '/:locale' do

to:

scope '/:locale', locale: /#{I18n.available_locales.join('|')}/ do