diff --git a/app/controllers/settings/theme_controller.rb b/app/controllers/settings/theme_controller.rb index f37131f1..58829a67 100644 --- a/app/controllers/settings/theme_controller.rb +++ b/app/controllers/settings/theme_controller.rb @@ -8,23 +8,8 @@ class Settings::ThemeController < ApplicationController def edit; end def update - update_attributes = params.require(:theme).permit(%i[ - primary_color primary_text - danger_color danger_text - success_color success_text - warning_color warning_text - info_color info_text - dark_color dark_text - light_color light_text - raised_background raised_accent - raised_text raised_accent_text - background_color body_text - muted_text input_color - input_text input_placeholder - ]) - if current_user.theme.nil? - current_user.theme = Theme.new update_attributes + current_user.theme = Theme.new theme_attributes current_user.theme.user_id = current_user.id if current_user.theme.save @@ -32,7 +17,7 @@ class Settings::ThemeController < ApplicationController else flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" ")) end - elsif current_user.theme.update(update_attributes) + elsif current_user.theme.update(theme_attributes) flash[:success] = t(".success") else flash[:error] = t(".error", errors: current_user.theme.errors.messages.flatten.join(" ")) @@ -44,4 +29,23 @@ class Settings::ThemeController < ApplicationController current_user.theme.destroy! redirect_to edit_settings_theme_path end + + private + + def theme_attributes + params.require(:theme).permit(%i[ + primary_color primary_text + danger_color danger_text + success_color success_text + warning_color warning_text + info_color info_text + dark_color dark_text + light_color light_text + raised_background raised_accent + raised_text raised_accent_text + background_color body_text + muted_text input_color + input_text input_placeholder + ]) + end end