次のルートが設定されています。
MyApp::Application.routes.draw do
scope "/:locale" do
...other routes
root :to => 'home#index'
end
root :to => 'application#detect_language'
end
これにより、次のようになります。
root /:locale(.:format) home#index
root / application#detect_language
これは問題ありません。
ただし、ロケールでルートを生成したい場合、問題が発生します。
root_path
/
どちらが正しいかを生成します。
root_path(:locale => :en)
/?locale=en
望ましくないものを生成します-私たちは欲しいです/en
それで、質問は、これは可能ですか、そしてどのように可能ですか?