photomix/app/models/role.rb

12 lines
521 B
Ruby
Raw Normal View History

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'
validates_uniqueness_of :name
acts_as_permissible
end