Support the ability for admins to delete users

This commit is contained in:
Michael Ball 2021-03-08 20:19:57 -08:00
parent 331e0a1610
commit 332bf8f1df
3 changed files with 28 additions and 5 deletions

View file

@ -66,10 +66,14 @@ module Admin
def edit; end
def delete
@user.destroy!
flash[:notice] = "User #{@user.id} (#{@user.emai}) successfully deleted."
redirect_to admin_users_path
def destroy
if @user.destroy
redirect_to admin_users_path,
notice: "User #{@user.id} (#{@user.email}) deleted."
else
redirect_to admin_users_path,
error: "User #{@user.id} (#{@user.emai}) could not be deleted. #{@user.full_messages.join(',')}"
end
end
private