Refactoring rooms
This commit is contained in:
parent
2c98ba9711
commit
6a373b5f6c
11 changed files with 135 additions and 52 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue