2013-01-07 09:04:09 +01:00
|
|
|
class Room < ActiveRecord::Base
|
2014-08-12 11:51:59 +03:00
|
|
|
attr_accessible :name, :size, :public, :conference_id
|
2013-01-07 09:04:09 +01:00
|
|
|
|
|
|
|
|
belongs_to :conference
|
|
|
|
|
has_many :events
|
|
|
|
|
|
|
|
|
|
before_create :generate_guid
|
|
|
|
|
|
2014-11-12 11:37:28 +01:00
|
|
|
validates :name, presence: true
|
|
|
|
|
|
|
|
|
|
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
|
|
|
|
|
|
|
|
|
|
validates :size, presence: true, if: :public?
|
|
|
|
|
|
2013-01-07 09:04:09 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def generate_guid
|
2014-06-23 19:07:50 +03:00
|
|
|
guid = SecureRandom.urlsafe_base64
|
2013-01-07 09:04:09 +01:00
|
|
|
self.guid = guid
|
|
|
|
|
end
|
2014-06-30 17:07:53 +02:00
|
|
|
end
|