闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
742 B

  1. # frozen_string_literal: true
  2. module Admin
  3. class SettingsController < BaseController
  4. def index
  5. @settings = Setting.all_as_records
  6. end
  7. def update
  8. @setting = Setting.where(var: params[:id]).first_or_initialize(var: params[:id])
  9. value = settings_params[:value]
  10. # Special cases
  11. value = value == 'true' if @setting.var == 'open_registrations'
  12. if @setting.value != value
  13. @setting.value = value
  14. @setting.save
  15. end
  16. respond_to do |format|
  17. format.html { redirect_to admin_settings_path }
  18. format.json { respond_with_bip(@setting) }
  19. end
  20. end
  21. private
  22. def settings_params
  23. params.require(:setting).permit(:value)
  24. end
  25. end
  26. end