1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[ci skip] Add missing setting locale code snippet.

This is for 3 Internationalizing your Application of i18n.md.

Missing the code as mentioned in 2.3, setting locale.

Without this, the example to add config/locales/pirate.yml will not work.
This commit is contained in:
Juanito Fatas 2013-09-09 23:47:38 +08:00
parent ad6e8a2fec
commit 451f433205

View file

@ -315,6 +315,17 @@ Yourapp::Application.routes.draw do
end
```
```ruby
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end
```
```ruby
# app/controllers/home_controller.rb
class HomeController < ApplicationController