You are here: Browse Railsplugins Role Requirement
Location: United States, Utah
There are many role-based security plug-ins out there. Often times, they are very complicated and much more than you need.
RoleRequirement focuses on a simple approach to role-based authentication. you don’t have to learn a new language in order to specify roles. Instead, RoleRequirement leverages the power of Ruby to strike a marvelous balance between simplicity and flexibility.
Basic Features:
Steps to using as easy as 1, 2, 3!
=== 1. Install acts_as_authenticated and role_requirement ===
See install instructions below. You must generate your User model from acts_as_authenticated and include AuthenticatedSystem in your ApplicationController, as usual.
=== 2. Add has_role? to your User model ===
{{{ class User < ActiveRecord::Base ... # has_role? simply needs to return true or false whether a user has a role or not. # It may be a good idea to have “admin” roles return true always # You can use either a habtm relationship for roles, or a simple enum field. # This example uses a habtm def has_role?(role) @roles ||= self.roles.collect(&:name) return true if @roles.include?(“admin”) (@roles.include?(role.to_s) ) end ... }}}
=== 3. Require a roles in your controllers ===
It’s easy as pie!
{{{
class Admin::Users < ApplicationController require_role “admin” end
}}}
Unlimited flexibility without the mess!
{{{
class Admin::Listings < ApplicationController require_role “contractor” require_role “admin”, :only => :destroy # don’t allow contractors to destroy
end
}}}
Installationscript/plugin install http://rolerequirement.googlecode.com/svn/tags/role_requirement/
HelpHere’s how to get help
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly