app/controllers/users_controller.rb
# same protections as edit to have double protection
same protections as edit to have double protection
same protections as edit to have double protection
def update
    @user = User.find(params[:id])
    if @user.id == session[:user_id] || current_user.role == 'admin' || current_user.role == 'moderator'
      if @user.update(user_params)
        redirect_to '/users'
      else
        render :edit
      end
    else
      render :edit
    end
  end
def update @user = User . find ( params [ :id ] ) if @user . id == session [ :user_id ] || current_user . role == 'admin' || current_user . role == 'moderator' if @user . update ( user_params ) redirect_to '/users' else render :edit end else render :edit end end
same protections as edit to have double protection
same protections as edit to have double protection