Repository URL to install this package:
|
Version:
4.0.0.pre.3 ▾
|
module Core
class Instructor < ActiveRecord::Base
belongs_to :organisation
has_many :assignments
has_many :events, through: :assignments
validates :name, presence: true
before_destroy :check_for_events
default_scope { order('created_at') }
private
def check_for_events
unless events.empty?
self.errors[:base] << 'Cannot delete Instructors with Events'
return false
end
end
end
end