Class: Hello::Internationalization::LocaleController

Inherits:
ApplicationController show all
Defined in:
app/controllers/hello/internationalization/locale_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /hello/locale



7
8
9
10
11
12
# File 'app/controllers/hello/internationalization/locale_controller.rb', line 7

def index
  respond_to do |format|
    format.html { render 'hello/internationalization/locales' }
    format.json { render json: { locales: view_context.available_locales_with_names } }
  end
end

#updateObject

POST /hello/locale



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/hello/internationalization/locale_controller.rb', line 15

def update
  business = Business::Internationalization::UpdateLocale.new(params['locale'])

  current_user && current_user.update!(locale: business.locale)
  use_locale(business.locale)

  respond_to do |format|
    format.html { redirect_to :back, notice: business.success_message }
    format.json { fail Hello::Errors::JsonNotSupported }
  end
end