# Saves the current user's appearance (sent by theme.js). The body replaces the whole saved # choice; an empty object resets the user to the default. class TonalmineAppearanceController < ApplicationController before_action :require_login def update prefs = params.to_unsafe_h.except('controller', 'action', 'tonalmine_appearance') errors = RedmineTonalmine::Appearance.errors(prefs) if errors.any? render json: {errors: errors}, status: :unprocessable_content else User.current.pref[:tonalmine] = RedmineTonalmine::Appearance.clean(prefs) User.current.pref.save head :no_content end end end