module NsSettingsUi class SettingsController < NsSettingsUi::ApplicationController layout NsSettingsUi.layout before_action :setting_from_id_param, only: [:update, :reset] def index @settings = Setting.order('`key`').all end def update @setting.value = params[:setting][:value] @setting.default_value = params[:setting][:default_value] @setting.save! 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 end end