This repository has been archived on 2021-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
greenlight/app/models/room.rb

21 lines
401 B
Ruby

class Room < ApplicationRecord
before_create :set_uid
belongs_to :user
has_one :meeting
def owned_by?(user)
return false if user.nil?
user.room == self
end
private
# Generates a uid for the room.
def set_uid
digest = user.id.to_s + user.provider + user.username
digest += user.uid unless user.uid.nil?
self.uid = Digest::SHA1.hexdigest(digest)[0..12]
end
end