Sha256: cc49abdf62d4bfb85faf009416e82362226bfdc523cad81662e9f110641a0763

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

require_dependency "sail/application_controller"

module Sail
  # ProfilesController
  #
  # This controller implements all profile related
  # APIs.
  class ProfilesController < ApplicationController
    def create
      respond_to do |format|
        format.js do
          @profile, @new_record = Sail::Profile.create_or_update_self(s_params[:name])
        end
      end
    end

    def switch
      respond_to do |format|
        format.js { Sail::Profile.switch(s_params[:name]) }
        format.json { Sail::Profile.switch(s_params[:name]) }
      end
    end

    def destroy
      respond_to do |format|
        format.js do
          @profile = Sail::Profile.find_by(name: s_params[:name]).destroy
        end
      end
    end

    private

    def s_params
      params.permit(:name, :locale)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sail-3.6.1 app/controllers/sail/profiles_controller.rb
sail-3.6.0 app/controllers/sail/profiles_controller.rb