Refactoring rooms

This commit is contained in:
chrisbr 2014-11-12 11:37:28 +01:00
parent 2c98ba9711
commit 6a373b5f6c
11 changed files with 135 additions and 52 deletions

View file

@ -6,13 +6,16 @@ class Room < ActiveRecord::Base
before_create :generate_guid
validates :name, presence: true
validates :size, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
validates :size, presence: true, if: :public?
private
def generate_guid
guid = SecureRandom.urlsafe_base64
# begin
# guid = SecureRandom.urlsafe_base64
# end while Person.where(:guid => guid).exists?
self.guid = guid
end
end