From a0feb16a6abc508d6d3d5eacb389c55e097a4176 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 5 Jul 2019 23:19:45 +0800 Subject: [PATCH] fix competition enroll bug --- app/controllers/competition_teams_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index c0bde5e4..5b68c433 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -153,7 +153,7 @@ class CompetitionTeamsController < ApplicationController # 新增加的成员 ids = new_member_ids - team_member_ids - raise @message unless check_member_enroll_limited?(@competition, ids) # 有成员已经加入其他战队,并且只能一次报名 + raise @message unless check_member_enroll_limited?(@competition, ids - [@team.user_id]) # 有成员已经加入其他战队,并且只能一次报名; 减去创建者 ids.each do |user_id| next if user_id.to_i == @team.user_id @@ -170,7 +170,7 @@ class CompetitionTeamsController < ApplicationController # 新增加的老师 ids = new_teacher_ids - teacher_ids - raise @message unless check_teacher_enroll_limited?(@competition, ids) # 有老师已经加入其他战队,并且只能一次报名 + raise @message unless check_teacher_enroll_limited?(@competition, ids - [@team.user_id]) # 有老师已经加入其他战队,并且只能一次报名;减去创建者 ids.each do |user_id| next if user_id.to_i == @team.user_id