Store selected site color scheme

This commit is contained in:
Anton Khorev 2024-11-16 18:13:03 +03:00
parent bad03267c1
commit 045af66d43
2 changed files with 35 additions and 1 deletions

View file

@ -21,7 +21,15 @@ class PreferencesController < ApplicationController
else
params[:user][:preferred_editor]
end
if current_user.save
success = current_user.save
if params[:site_color_scheme]
site_color_scheme_preference = current_user.preferences.find_or_create_by(:k => "site.color_scheme")
success &= site_color_scheme_preference.update(:v => params[:site_color_scheme])
end
if success
# Use a partial so that it is rendered during the next page load in the correct language.
flash[:notice] = { :partial => "preferences/update_success_flash" }
redirect_to preferences_path