Repository URL to install this package:
|
Version:
4.0.0.pre.3 ▾
|
module Core
class Organisation < ActiveRecord::Base
has_many :organisation_venues, dependent: :destroy
has_many :venues, through: :organisation_venues
has_many :events, through: :organisation_venues
has_many :instructors, dependent: :destroy
has_many :passes, dependent: :destroy
belongs_to :owner, class_name: 'User', foreign_key: 'owner_id'
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 Organisations with Events'
return false
end
end
end
end