hello-gem/hello

View on GitHub
app/controllers/hello/internationalization/locale_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
Missing magic comment `# frozen_string_literal: true`.
module Hello
module Internationalization
class LocaleController < ApplicationController
dont_kick_people
 
# GET /hello/locale
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
 
# POST /hello/locale
Assignment Branch Condition size for update is too high. [16.06/15]
def update
business = Business::Internationalization::UpdateLocale.new(params['locale'])
 
Use safe navigation (`&.`) instead of checking if an object exists before calling the method.
current_user && current_user.update!(locale: business.locale)
use_locale(business.locale)
 
respond_to do |format|
format.html { redirect_back fallback_location: root_path, notice: business.success_message }
Always use `raise` to signal exceptions.
format.json { fail Hello::Errors::JsonNotSupported }
end
end
end
end
end