settings_controller.rb 631 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. module Admin
  3. class SettingsController < BaseController
  4. def edit
  5. authorize :settings, :show?
  6. @admin_settings = Form::AdminSettings.new
  7. end
  8. def update
  9. authorize :settings, :update?
  10. @admin_settings = Form::AdminSettings.new(settings_params)
  11. if @admin_settings.save
  12. flash[:notice] = I18n.t('generic.changes_saved_msg')
  13. redirect_to edit_admin_settings_path
  14. else
  15. render :edit
  16. end
  17. end
  18. private
  19. def settings_params
  20. params.require(:form_admin_settings).permit(*Form::AdminSettings::KEYS)
  21. end
  22. end
  23. end