I want to make my Rails3.2 app i18n according to the following site and to include a locale parameter in the URL path. (http://www.wordchuck.com/en/website/blogs/5)
I implemented as
scope ':locale' do
resources :nodes
end
and other methods
def set_locale
I18n.locale = params[:locale] if params.include?('locale')
end
def default_url_options(options = {})
options.merge!({ :locale => I18n.locale })
end
in my application_controller.rb.
And now I can confirm that
http://myhost/ja/nodes/explore or http://myhost/en/nodes/explore
pass, but
http://myhost/nodes/explore
got "No route matches [GET] "/nodes/explore"" error.
I wonder that could be :locale is nil.
To make nil :locale enable and defaults to "en" when :locale is nil, what should I do?