osem-fcy/app/models/room.rb
Ana c5c7cbeab9 Delete EventSchedules when a Room is deleted
We should remove all the EventSchedules that belongs_to a Room when it is deleted. Otherwise both the public and admin schedule would fail.
2016-08-18 16:19:15 +02:00

23 lines
499 B
Ruby

class Room < ActiveRecord::Base
belongs_to :venue
has_many :event_schedules, dependent: :destroy
has_paper_trail ignore: [:guid], meta: { conference_id: :conference_id }
before_create :generate_guid
validates :name, :venue_id, presence: true
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
private
def generate_guid
guid = SecureRandom.urlsafe_base64
self.guid = guid
end
def conference_id
venue.conference_id
end
end