1 class PreferencesController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
7 authorize_resource :class => false
9 before_action :check_database_readable
10 before_action :check_database_writable, :only => [:update]
17 current_user.languages = params[:user][:languages].split(",")
19 current_user.preferred_editor = if params[:user][:preferred_editor] == "default"
22 params[:user][:preferred_editor]
25 success = current_user.save
27 if params[:site_color_scheme]
28 site_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "site.color_scheme")
29 success &= site_color_scheme_preference.update(:v => params[:site_color_scheme])
33 # Use a partial so that it is rendered during the next page load in the correct language.
34 flash[:notice] = { :partial => "preferences/update_success_flash" }
35 redirect_to preferences_path
37 flash.now[:error] = t ".failure"