osem-fcy/app/models/room.rb
Ana c047ffd699 New associations and models: schedule versioning
For the schedule versioning in the admin interface (having multiple possible shcedules) we need to change some models and associations. It has also been create a rake:move_events_attributes task to migrate the data.

User Interface addapted to make use of the introduced associations and models
2016-08-11 15:06:52 +02:00

17 lines
372 B
Ruby

class Room < ActiveRecord::Base
belongs_to :venue
has_many :event_schedules, dependent: :nullify
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
end