diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 0d78fb58..817de9be 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -145,7 +145,7 @@ class CompetitionTeamsController < ApplicationController # 老师身份加入战队 if User.current.user_extensions.identity == 0 - teacher_staff = @competition.where(category: 'teacher').first + teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? @status, @message = -1, '该竞赛不能配备导师' @@ -158,7 +158,7 @@ class CompetitionTeamsController < ApplicationController end team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true) else - max_member_count = @competition.where('category != "teacher"').sum(:maximum) + max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) if team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' return