blob: 17e3f199c3205b8c5052cb72509f24a82c993054 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
class ChatRoom < ApplicationRecord
has_many :chat_messages
validates :gid, :name, presence: true, uniqueness: true
attribute :permission_level, :integer, default: 1
enum permission_level: {
banned: 0,
player: 1,
helper: 2,
builder: 3,
admin: 4,
developer: 5,
owner: 6
}
def self.accessible_to(user)
all.select { |x| x.accessible_to?(user) }
end
def accessible_to?(user)
user.has_permission_or_higher?(self.permission_level)
end
def short_name
self.name[0..6]
end
end
|