Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/user.rb
Instance Method Summary collapse
Instance Method Details
#last_admin? ⇒ Boolean
18 19 20 |
# File 'app/models/user.rb', line 18 def last_admin? self.has_role?("admin") and User.admins.size == 1 ? true : false end |
#role_list ⇒ Object
13 14 15 16 |
# File 'app/models/user.rb', line 13 def role_list roles = Role.all user_roles = roles.map{|r| r if self.has_role?(r.name) } end |
#set_roles(roles) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/user.rb', line 22 def set_roles(roles) if self.last_admin? self.has_no_roles! self.has_role!("admin") else self.has_no_roles! end return unless roles for role in roles self.has_role!(role) end end |