使用Rails 4和I18n。
当我调用
之类的路径时conversation_path(locale: :de, 1)
它给我一个错误说
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路线给了我
conversation_de GET /:locale/conversations/:id(.:format) frontend/conversations#show {:locale=>"de"}
conversation_en GET /:locale/conversations/:id(.:format) frontend/conversations#show {:locale=>"en"}
我错过了什么吗?
答案 0 :(得分:1)
尝试更改routes.rb
scope '/:locale' do
为:
scope '/:locale', locale: /#{I18n.available_locales.join('|')}/ do