This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/models/user/role.rb

28 lines
593 B
Ruby

class Role
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
field :title, localize: true
has_many :sub_roles, :autosave => true, :dependent => :destroy
has_many :users
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
# Get an role from key
def self.get_role_from_key(key)
self.first(:conditions => {:key => key})
end
end