diff --git a/app/controllers/users/settings/user_teams_controller.rb b/app/controllers/users/settings/user_teams_controller.rb index de9f224af..dd9b468be 100644 --- a/app/controllers/users/settings/user_teams_controller.rb +++ b/app/controllers/users/settings/user_teams_controller.rb @@ -139,7 +139,8 @@ module Users @user_t.destroy(new_owner) end - rescue Exception + rescue StandardError => e + Rails.logger.error e.message invalid = true end end diff --git a/app/models/user_team.rb b/app/models/user_team.rb index 69f7a9bbc..696a1e9b4 100644 --- a/app/models/user_team.rb +++ b/app/models/user_team.rb @@ -18,7 +18,7 @@ class UserTeam < ApplicationRecord def destroy_associations # Destroy the user from all team's projects - team.projects.joins(:user_projects).where(user_projects: { user: user }).destroy_all + user.user_projects.joins(:project).where(project: team.projects).destroy_all # destroy all assignments UserAssignments::RemoveUserAssignmentJob.perform_now(user, team) end