photomix/app/models/role.rb
2009-06-05 14:18:03 +02:00

12 lines
No EOL
521 B
Ruby

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