semester.rb 379 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1
2
3
# Contains logic having to do with the +Semester+ model.
#
# A +Semester+ is a simple model that consists of a +year+ and a +season+, e.g. "Fall 2018".
Zac Wood's avatar
Zac Wood committed
4
class Semester < ApplicationRecord
5
6
  has_many :courses
  
Zac Wood's avatar
Zac Wood committed
7
8
9
  # Ensure necessary fields are present.
  validates :year, presence: true
  validates :season, presence: true
10
11
12
13

  def courses
    Course.where semester_id: id
  end
Zac Wood's avatar
Zac Wood committed
14
end