stonean

trying to be better than I was yesterday

Examples of basic permissions

The simplest example of a permission is:

set_permission(:manage_users).
  with_controller(:users)

This will define a permission called :manage_users which represents all methods on the users controller.

set_permission(:my_account).
  with_controller(:users).
  only_methods(:show, :update)

This will define a permission called :my_account which represents only the show and update methods on the users controller.

 set_permission(:manage_trends).
  with_controller(:trends).except_methods(:destroy).
  and_controller(:votes).
  and_controller(:comments).except_methods(:destroy)

The above is an example from RubyTrends.com. This is used as a protected method (all logged in users have these rights). This defines a permission called :manage_trends which is all methods on the trends controller (except :destroy) plus all methods on the votes controller plus all methods on the comments controller (except destroy).

Copyright © 2010 stonean. All rights reserved.
Powered by Thoth.