Cannot remove user that owns a project.

Cannot remove user that owns a project.

Make lines shorter, set alert, use path instead of url.
This commit is contained in:
Marin Jankovski 2012-11-02 12:26:41 +01:00 committed by Sytse Sijbrandij
parent 2ff36e74eb
commit 19e8473eb7

View file

@ -98,6 +98,9 @@ class Admin::UsersController < AdminController
def destroy def destroy
@admin_user = User.find(params[:id]) @admin_user = User.find(params[:id])
if @admin_user.my_own_projects.count > 0
redirect_to admin_users_path, alert: "User is a project owner and can't be removed." and return
end
@admin_user.destroy @admin_user.destroy
respond_to do |format| respond_to do |format|