Skip to content

Commit

Permalink
Issue #238
Browse files Browse the repository at this point in the history
Fixing more than one class_enrollment bug.
  • Loading branch information
braganholo authored Dec 1, 2017
1 parent 3777fa7 commit 53b2eb0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/class_enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ class ClassEnrollment < ActiveRecord::Base

def check_multiple_class_enrollment_allowed
return if not self.course_class
other_enrollments = ClassEnrollment.
other_class_enrollments = ClassEnrollment.
joins(:course_class => {:course => :course_type}).
includes(:course_class => {:course => :course_type}).
where(CourseType.arel_table[:allow_multiple_classes].eq(false)).
where(:enrollment_id => self.enrollment_id).
where(ClassEnrollment.arel_table[:situation].not_eq(DISAPPROVED)).
where(Course.arel_table[:id].eq( self.course_class.course_id)).
where.not(:id => self.id).
group(:enrollment_id).
having("count(course_id) > 1")
having("count(course_id) > 0")


unless other_enrollments.empty?
unless other_class_enrollments.empty?
self.errors.add(:course_class, :multiple_class_enrollments_not_allowed)
end
end
Expand Down

0 comments on commit 53b2eb0

Please sign in to comment.