Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- lib/generators/lab/setup/templates/devise/devise_user.rb
Constant Summary collapse
- ROLES =
%w[user admin]
Instance Method Summary collapse
- #add_role(role) ⇒ Object
- #has_role?(role) ⇒ Boolean
- #role_symbols ⇒ Object
- #roles ⇒ Object
- #roles=(roles) ⇒ Object
Instance Method Details
#add_role(role) ⇒ Object
18 19 20 21 |
# File 'lib/generators/lab/setup/templates/devise/devise_user.rb', line 18 def add_role(role) r = self.roles.push(role) self.roles = r end |
#has_role?(role) ⇒ Boolean
27 28 29 |
# File 'lib/generators/lab/setup/templates/devise/devise_user.rb', line 27 def has_role?(role) roles.include?(role) ? true : false end |
#role_symbols ⇒ Object
23 24 25 |
# File 'lib/generators/lab/setup/templates/devise/devise_user.rb', line 23 def role_symbols roles.map(&:to_sym) end |