Commit 19e8473eb7dd456b64315b1b9e62c780ace98fef
Committed by
Sytse Sijbrandij
1 parent
2ff36e74
Exists in
master
and in
4 other branches
Cannot remove user that owns a project.
Cannot remove user that owns a project. Make lines shorter, set alert, use path instead of url.
Showing
1 changed file
with
3 additions
and
0 deletions
Show diff stats
app/controllers/admin/users_controller.rb
... | ... | @@ -98,6 +98,9 @@ class Admin::UsersController < AdminController |
98 | 98 | |
99 | 99 | def destroy |
100 | 100 | @admin_user = User.find(params[:id]) |
101 | + if @admin_user.my_own_projects.count > 0 | |
102 | + redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return | |
103 | + end | |
101 | 104 | @admin_user.destroy |
102 | 105 | |
103 | 106 | respond_to do |format| | ... | ... |