Module: HasRoles::MacroMethods

Defined in:
lib/has_roles.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) has_roles

Indicates that the model has roles. This will create the following associations:

  • role_assignments - The join association for roles that have been assigned to a record in this model

  • roles - The actual roles through the join association



12
13
14
15
16
17
# File 'lib/has_roles.rb', line 12

def has_roles
  has_many :role_assignments, :class_name => 'RoleAssignment', :as => :assignee, :dependent => :destroy
  has_many :roles, :through => :role_assignments
  
  include HasRoles::InstanceMethods
end