Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
rails
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
VERSION
init.rb
install.rb
objectreload-roles.gemspec
uninstall.rb

README

Roles
=====

Simple roles system.

Migrations
=====

  create_table :roles do |t|
    t.string :name
  end
  Role.create(:name => "administrator")


  create_table :privileges, :id => false do |t|
    t.integer :user_id
    t.integer :role_id
  end


Examples
=======

Available methods if administrator role has been created: 
    user.administrator? 
    user.is?(:administrator)
    user.is_not?(:administrator)

Add more roles in the migration: moderator, uploader etc.
    user.moderator?
    user.is?(:uploader)

Find all users with moderator role
    User.find_with_role(:moderator)
or
    Role[:moderator].users


Copyright (c) 2008-2009 Mariusz Pietrzyk, 2009-2010 Mateusz Drożdżyński, released under the MIT license
Something went wrong with that request. Please try again.