skill-assessment-app/app/controllers/admin/profile_controller.rb
2016-09-21 15:50:02 -05:00

33 lines
660 B
Ruby

# frozen_string_literal: true
module Admin
class ProfileController < AdminController
def view
authorize current_user
end
def edit
@user = current_user
authorize @user
end
def update
@user = current_user
authorize @user
if @user.update_attributes(user_params)
redirect_to admin_profile_path,
flash: { success: "Sucessfully updated profile" }
else
flash[:error] = "Failed to update profile."
render :edit
end
end
private
def user_params
params.require(:user).permit(policy(User).permitted_attributes)
end
end
end