2009-06-05 14:18:03 +02:00
|
|
|
class Role < ActiveRecord::Base
|
|
|
|
has_many :role_memberships, :as => :roleable, :dependent => :destroy
|
|
|
|
has_many :roles, :through => :role_memberships, :source => :role
|
|
|
|
|
|
|
|
has_many :roleables, :class_name => "RoleMembership", :foreign_key => "role_id", :dependent => :destroy
|
|
|
|
has_many :subroles, :through => :roleables, :source => :roleable, :source_type => 'Role'
|
|
|
|
has_many :users, :through => :roleables, :source => :roleable, :source_type => 'User'
|
|
|
|
|
2010-12-13 05:17:49 +01:00
|
|
|
validates :name, :presence => true, :uniqueness => true
|
2009-06-05 14:18:03 +02:00
|
|
|
|
|
|
|
acts_as_permissible
|
|
|
|
end
|