Class | Assignment
In: | app/models/assignment.rb
Parent: | ActiveRecord::Base

### Methods

before_destroy validate

### Public Instance methods

before_destroy()

[Source]

        # File app/models/assignment.rb, line 15
    15:   def before_destroy()
    16:     # WE DO NOT ALLOW TO DELETE ASSIGNMENT IF GRADES EXIST FOR IT (I or G)
    17:     if Igrade.exists?(:assignment_id => "#{self.id}") ||
    18:        Ggrade.exists?(:assignment_id => "#{self.id}")
    19:       errors.add_to_base(
    20:       "Can't delete graded assignment, Edit it or delete all grades first")
    21:       false
    22:     end
    23:   end

validate()

[Source]

        # File app/models/assignment.rb, line 4
     4:   def validate
     5:     # THIS WILL ENFORCE THAT BOTH First_Name and Last_Name WILL BE ENTERED
     6:     errors.add_on_empty %w( description due_date)
     7:     if self.due_date < Date.today
     8:       errors.add("Assignment due date cannot be in the past. It")
     9:     end
    10:   end

[Validate]