skill-assessment-app/app/controllers/admin/profile_controller.rb

33 lines
660 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-08-24 10:43:33 -05:00
module Admin
2016-08-24 12:53:21 -05:00
class ProfileController < AdminController
2016-08-24 10:43:33 -05:00
def view
2016-09-21 11:03:45 -05:00
authorize current_user
2016-08-24 10:43:33 -05:00
end
def edit
@user = current_user
2016-09-21 11:03:45 -05:00
authorize @user
2016-08-24 10:43:33 -05:00
end
def update
@user = current_user
2016-09-21 11:03:45 -05:00
authorize @user
2016-08-24 12:53:21 -05:00
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
2016-08-24 10:43:33 -05:00
end
2016-08-24 15:02:32 -05:00
private
def user_params
2016-09-21 15:50:02 -05:00
params.require(:user).permit(policy(User).permitted_attributes)
2016-08-24 12:53:21 -05:00
end
2016-08-24 10:43:33 -05:00
end
end