1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :trackable,
:confirmable, :lockable
has_many :characters
belongs_to :active_character, class_name: "Character", optional: 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 has_permission_or_higher?(permission_level)
User.permission_levels[self.permission_level] >= User.permission_levels[permission_level]
end
end
|