1 # frozen_string_literal: true
 
   4   class PreferencesController < ApplicationController
 
   7     before_action :authorize_web
 
   8     before_action :set_locale
 
  10     authorize_resource :class => :preferences
 
  12     before_action :check_database_readable
 
  13     before_action :check_database_writable, :only => :update
 
  19         # Use a partial so that it is rendered during the next page load in the correct language.
 
  20         flash[:notice] = { :partial => "preferences/preferences/update_success_flash" }
 
  21         referer = safe_referer(params[:referer]) if params[:referer]
 
  22         redirect_to referer || { :action => :show }
 
  24         flash.now[:error] = t "failure", :scope => "preferences.preferences.update"