1
0

settings_controller.rb 709 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. module Admin
  3. class SettingsController < BaseController
  4. def show
  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 after_update_redirect_path
  14. else
  15. render :show
  16. end
  17. end
  18. private
  19. def after_update_redirect_path
  20. raise NotImplementedError
  21. end
  22. def settings_params
  23. params.require(:form_admin_settings).permit(*Form::AdminSettings::KEYS)
  24. end
  25. end
  26. end