Sha256: 79e3a3acfbc688bb3fd477bb5d3ad0d9f0562575466e1ecfd10efc0d521726aa

Contents?: true

Size: 735 Bytes

Versions: 6

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

module Sail
  class SettingsController < ApplicationController
    def index
      @settings = Setting.by_name(params[:query]).paginated(index_params[:page])
      fresh_when(@settings)
    end

    def update
      respond_to do |format|
        @setting, @successful_update = Setting.set(params[:name], params[:value])
        format.js {}
        format.json { @successful_update ? head(:ok) : head(:conflict) }
      end
    end

    def show
      respond_to do |format|
        format.json do
          setting = Sail::Setting.get(params[:name])
          render json: { value: setting }
        end
      end
    end

    private

    def index_params
      params.permit(:page)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sail-1.4.1 app/controllers/sail/settings_controller.rb
sail-1.4.0 app/controllers/sail/settings_controller.rb
sail-1.3.0 app/controllers/sail/settings_controller.rb
sail-1.2.2 app/controllers/sail/settings_controller.rb
sail-1.2.1 app/controllers/sail/settings_controller.rb
sail-1.2.0 app/controllers/sail/settings_controller.rb