Has Roles plugin

Plugin details

has_roles demonstrates a reference implementation for handling role management.

Websitehttp://wiki.pluginaweek.org/Has_roles Repositoryhttp://svn.pluginaweek.org/trunk/has_roles Author Aaron Pfeifer Tags role LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.pluginaweek.org/trunk/has_roles

Description
============

One of the easiest and most straightforward techniques for adding role management and authorization to specific parts of your application is restricting usage on controller/action-basis. Each role defined in your system is mapped to one or more permissions. Each permission is a combination of a controller and action.

Usage
========

Checking a user's authorization
--------------------------------------

Below is an example of checking a user's authorization for a url before display information:

app/views/layouts/application.rhtml:

  <% if authorized_for?(:controller => 'admin/users') -%>
  < p>Read to start administering your website?< /p>
  <% end -%>


Global authorization
----------------------------

You can define a global permission that will add access for all controllers by defining a controller with the path 'application'. See the test fixtures for more information.

Running migrations
--------------------------

To migrate the tables required for this plugin, you can either run the migration from the command line like so:

  rake db:migrate:plugins PLUGIN=has_roles


or (more ideally) generate a migration file that will integrate into your main application's migration path:

  ruby script/generate plugin_migration has_roles

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: obrie572, 3 months ago