diff --git a/app/models/course.rb b/app/models/course.rb index 2f561bba7..0ac879905 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -146,7 +146,7 @@ class Course < ApplicationRecord def teacher_group(user_id) data = if teacher_course_groups.exists?(user_id: user_id) - teacher_course_groups.joins(:course_group).where(user_id: user_id) + teacher_course_groups.joins(:course_group).where(user_id: user_id).distinct .pluck('course_groups.id', 'course_groups.name') else course_groups.pluck(:id, :name)