Skip to content
kristianmandrup edited this page May 9, 2011 · 5 revisions

role=

@guest_user.role = :admin

roles=

@guest_user.roles = :admin, :guest

remove_role

@admin_user.remove_role :admin

remove_roles

@admin_user.remove_roles :admin, :guest

add_role

@admin_user.add_role :editor

add_roles

@admin_user.add_roles :editor, :guest

exchange_role

@guest_user.exchange_role :guest, :with => :admin

exchange_roles

@guest_user.exchange_roles :guest, :editor :with => :admin

Class methods

The following methods can be called on a given User class where Roles::ActiveRecord is included.

valid_roles_are

Admin.valid_roles_are :guest, :admin

Defines which roles are valid for the given User class.

default_role=

AdminUser.default_role = :super_admin
@admin_user = AdminUser.new.role.should == :super_admin

Set the default role for the class.

For more methods see the specs