Sha256: d747f6df794ad98e66e27fe1924f0b9436dea9c4c3b3b0d63dadbfc87499a6ea

Contents?: true

Size: 674 Bytes

Versions: 3

Compression:

Stored size: 674 Bytes

Contents

module NsSettingsUi
  class SettingsController < NsSettingsUi::ApplicationController
    layout NsSettingsUi.layout
    before_action :setting_from_id_param, only: [:update, :reset]

    def index
      @settings = Setting.order(Arel.sql('`key`')).all
    end

    def update
      @setting.update!(setting_params)
      render partial: 'update'
    end

    def reset
      @setting.value = @setting.default_value
      @setting.save!
      render partial: 'update'
    end

    private

    def setting_from_id_param
      @setting = Setting.find(params[:id])
    end

    def setting_params
      params.require(:setting).permit(:value, :default_value)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ns_settings_ui-1.7.0 app/controllers/ns_settings_ui/settings_controller.rb
ns_settings_ui-1.6.1 app/controllers/ns_settings_ui/settings_controller.rb
ns_settings_ui-1.6.0 app/controllers/ns_settings_ui/settings_controller.rb