grantcallendar/app/controllers/settings/settings_controller.rb

64 lines
1.7 KiB
Ruby

# frozen_string_literal: true
# module settings
module Settings
# Users
class SettingsController < ApplicationController
before_action :authenticate_user!
before_action :set_setting, only: %i[show edit update]
def index
@settings = Setting.all
end
def show; end
def new
@setting = Setting.new
end
def edit; end
def create
@setting = Setting.new(setting_params)
respond_to do |format|
if @setting.save
# @user.confirm
# @user.save
format.html { redirect_to settings_settings_url, notice: 'Utworzono pomyślnie.' }
format.json { render :show, status: :created, location: @setting }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @setting.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @setting.update_attributes(setting_params)
format.html { redirect_to settings_settings_url, notice: 'Zaktualizowano pomyślnie.' }
format.json { render :show, status: :ok, location: @setting }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @setting.errors, status: :unprocessable_entity }
end
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_setting
@setting = Setting.first
end
# Only allow a list of trusted parameters through.
def setting_params
params.require(:setting).permit(:disclaimer_clause, :privacy_policy,
:statute)
end
end
end