From d1968a63c10b293f6ae96a80b33afb0d0ed8806b Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 25 Sep 2024 11:47:15 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E7=94=A8=E6=88=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86,=E5=A4=9A=E4=B8=AAowner?= =?UTF-8?q?=E6=97=B6,=E4=BB=85=E5=B0=86=E7=94=A8=E6=88=B7=E4=BB=8E?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=A7=BB=E9=99=A4,=20=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admins/users_controller.rb b/app/controllers/admins/users_controller.rb index 09ef06ffe..ba7b70d29 100644 --- a/app/controllers/admins/users_controller.rb +++ b/app/controllers/admins/users_controller.rb @@ -31,9 +31,9 @@ class Admins::UsersController < Admins::BaseController organizations = Organization.where(id: org_ids) organizations.each do |org| # org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}) - org.team_users.joins(:team).where(teams: {authorize: %w(owner)}) + owner_count = org.team_users.joins(:team).where(teams: {authorize: %w(owner)}).count # 多个owner时,仅将用户从组织移除, 一个时直接删除 - if org.count > 1 + if owner_count > 1 org.team_users.joins(:team).where(user_id: @user.id, teams: {authorize: %w(owner)}).destroy_all org.organization_users.where(user_id: @user.id, organization_id: org.id).destroy_all else