base_controller.rb 575 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class Settings::Preferences::BaseController < Settings::BaseController
  3. def show; end
  4. def update
  5. if current_user.update(user_params)
  6. I18n.locale = current_user.locale
  7. redirect_to after_update_redirect_path, notice: I18n.t('generic.changes_saved_msg')
  8. else
  9. render :show
  10. end
  11. end
  12. private
  13. def after_update_redirect_path
  14. raise 'Override in controller'
  15. end
  16. def user_params
  17. params.require(:user).permit(:locale, :time_zone, chosen_languages: [], settings_attributes: UserSettings.keys)
  18. end
  19. end