2017-01-13 04:46:24 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
module Admin
|
|
|
|
class SettingsController < BaseController
|
2022-10-22 18:44:41 +09:00
|
|
|
def show
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize :settings, :show?
|
2019-03-23 22:07:04 +09:00
|
|
|
|
2017-07-12 10:24:04 +09:00
|
|
|
@admin_settings = Form::AdminSettings.new
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
2017-01-13 04:46:24 +09:00
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
def update
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize :settings, :update?
|
|
|
|
|
2019-03-23 22:07:04 +09:00
|
|
|
@admin_settings = Form::AdminSettings.new(settings_params)
|
2017-05-05 01:12:44 +09:00
|
|
|
|
2019-03-23 22:07:04 +09:00
|
|
|
if @admin_settings.save
|
|
|
|
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
2022-10-22 18:44:41 +09:00
|
|
|
redirect_to after_update_redirect_path
|
2019-03-23 22:07:04 +09:00
|
|
|
else
|
2022-10-22 18:44:41 +09:00
|
|
|
render :show
|
2019-03-23 22:07:04 +09:00
|
|
|
end
|
2017-01-13 04:46:24 +09:00
|
|
|
end
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
private
|
2017-04-04 22:26:57 +09:00
|
|
|
|
2022-10-22 18:44:41 +09:00
|
|
|
def after_update_redirect_path
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
def settings_params
|
2019-03-23 22:07:04 +09:00
|
|
|
params.require(:form_admin_settings).permit(*Form::AdminSettings::KEYS)
|
2017-04-21 00:18:09 +09:00
|
|
|
end
|
2017-04-04 22:26:57 +09:00
|
|
|
end
|
2017-01-13 04:46:24 +09:00
|
|
|
end
|