Class: ThemeSettingsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ThemeSettingsController
- Defined in:
- app/controllers/theme_settings_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
4 5 6 7 8 |
# File 'app/controllers/theme_settings_controller.rb', line 4 def edit @theme_setting = ThemeSetting.current @defaults = Studio.theme_config @preview_css = Studio::ThemeResolver.new(@theme_setting.resolved_colors).to_css end |
#regenerate ⇒ Object
25 26 27 28 |
# File 'app/controllers/theme_settings_controller.rb', line 25 def regenerate Rails.cache.delete("studio/theme/#{Studio.app_name}") redirect_to admin_theme_path, notice: "Theme cache cleared." end |
#update ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/theme_settings_controller.rb', line 10 def update @theme_setting = ThemeSetting.find_or_initialize_by(app_name: Studio.app_name) rescue_and_log(target: @theme_setting) do @theme_setting.update!(theme_params) Rails.cache.delete("studio/theme/#{Studio.app_name}") redirect_to admin_theme_path, notice: "Theme saved." end rescue StandardError => e @defaults = Studio.theme_config @preview_css = Studio::ThemeResolver.new(@theme_setting.resolved_colors).to_css flash.now[:alert] = "Error saving theme: #{e.}" render :edit, status: :unprocessable_entity end |