KyivKrishnaAcademy/ved_akadem_students

View on GitHub
app/controllers/locales_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class LocalesController < ApplicationController
  skip_before_action :authenticate_person!

  def toggle
    locale = I18n.locale == :ru ? :uk : :ru

    if current_person.present?
      current_person.update_column(:locale, locale)
    else
      session[:locale] = locale
    end

    redirect_back fallback_location: root_path
  end
end