KyivKrishnaAcademy/ved_akadem_students

View on GitHub
app/controllers/ui/base_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module Ui
  class BaseController < ApplicationController
    respond_to :json

    skip_before_action :set_locale

    private

    def user_not_authorized
      render json: { error: :not_authorized }, status: :unauthorized
    end

    def respond_with_interaction(klass, resource = nil)
      interaction = klass.new(user: current_person, params: params, resource: resource)

      render json: interaction, status: interaction.try(:status) || :ok
    end
  end
end