class Igrade < ActiveRecord::Base
  #validate_existence_of IS A PLUGIN FOR REFERENTIAL INTEGRITY
  # VERIFICATION WRITTEN BY: JOSH SUSSER OF PIVOTAL LABS. IT IS LISTED
  # HERE: http://svn.hasmanythrough.com/public/plugins/validates_existence/
  # UNDER MIT FREE LICENSE:
  # http://svn.hasmanythrough.com/public/plugins/validates_existence/MIT-LICENSE
  belongs_to :student
  validates_existence_of :student
  belongs_to :assignment
  validates_existence_of :assignment
  validates_numericality_of :grade, :less_than_or_equal_to => 100,
                                    :greater_than_or_equal_to => 0 
  validates_uniqueness_of :student_id, :scope => :assignment_id,
  :message => "has a grade already for this assignment, please use edit"
end
