Sha256: 30690799d996f015b0115c5adca16066adbba76cdec895e4fc942a8fa7c2152c

Contents?: true

Size: 757 Bytes

Versions: 6

Compression:

Stored size: 757 Bytes

Contents

module Gaku
  class ClassGroup < ActiveRecord::Base

    include Notes

    has_many :enrollments, class_name: 'Gaku::ClassGroupEnrollment'
    has_many :students, through: :enrollments

    has_many :class_group_course_enrollments, dependent: :destroy
    has_many :courses, through: :class_group_course_enrollments

    has_many :semester_class_groups, dependent: :destroy
    has_many :semesters, through: :semester_class_groups

    validates :name, presence: true

    scope :without_semester, -> {
                                  includes(:semester_class_groups)
                                  .where(gaku_semester_class_groups: {class_group_id: nil})
                                }

    def to_s
      "#{grade} - #{name}"
    end

  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gaku_core-0.0.3 app/models/gaku/class_group.rb
gaku-0.0.3 core/app/models/gaku/class_group.rb
gaku-0.0.2 core/app/models/gaku/class_group.rb
gaku_core-0.0.2 app/models/gaku/class_group.rb
gaku-0.0.1 core/app/models/gaku/class_group.rb
gaku_core-0.0.1 app/models/gaku/class_group.rb