Class: Role

Inherits:
ApplicationRecord
  • Object
show all
Extended by:
FriendlyId
Includes:
MasterModel
Defined in:
app/models/role.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MasterModel

#set_display_name

Class Method Details

.all_cacheObject



16
17
18
19
20
21
22
# File 'app/models/role.rb', line 16

def self.all_cache
  if Rails.env == 'production'
    Rails.cache.fetch('role_all'){ Role.select(:name).all }
  else
    Role.select(:name)
  end
end

.default_roleObject



28
29
30
# File 'app/models/role.rb', line 28

def self.default_role
  Role.find_by(name: 'Guest')
end

Instance Method Details

#clear_all_cacheObject



24
25
26
# File 'app/models/role.rb', line 24

def clear_all_cache
  Rails.cache.delete('role_all')
end

#localized_nameObject



12
13
14
# File 'app/models/role.rb', line 12

def localized_name
  display_name.localize
end