1
0
MSU-Course-Alerter/app/models/alert.rb

38 lines
1.1 KiB
Ruby

class Alert < ActiveRecord::Base
attr_accessible :alerted, :course, :department, :user_id, :semester
validates :department, :presence => true,
:length => {
:minimum => 2,
:maximum => 4
},
:format => {
:with => /\A[A-Za-z]+\Z/
}
validates :course, :presence => true,
:length => {
:minimum => 3,
:maximum => 4
},
:format => {
:with => /\A[0-9]+[A-Za-z]?\Z/
}
validates :user_id, :presence => true,
:numericality => {
only_integer: true
}
validates :semester, :presence => true
def alerted?
@alerted
end
def course_name
"#{self.department} #{self.course}"
end
def sections
end
end