gitlab-org--gitlab-foss/app/controllers/profiles/preferences_controller.rb
Annabel Dunstone Gray 9b177bb7c9 Revert "Merge branch 'revert-f2421b2b' into 'master'"
This reverts merge request !14148
2017-09-11 15:44:42 +00:00

42 lines
874 B
Ruby

class Profiles::PreferencesController < Profiles::ApplicationController
before_action :user
def show
end
def update
begin
result = Users::UpdateService.new(user, preferences_params).execute
if result[:status] == :success
flash[:notice] = 'Preferences saved.'
else
flash[:alert] = 'Failed to save preferences.'
end
rescue ArgumentError => e
# Raised when `dashboard` is given an invalid value.
flash[:alert] = "Failed to save preferences (#{e.message})."
end
respond_to do |format|
format.html { redirect_to profile_preferences_path }
format.js
end
end
private
def user
@user = current_user
end
def preferences_params
params.require(:user).permit(
:color_scheme_id,
:layout,
:dashboard,
:project_view,
:theme_id
)
end
end