Supported ruby versions
Tested to work with:
- Ruby 1.9+
Currently doesn’t support:
- Ruby 1.8.7
Should I use CanTango for my permission requirements?
gem install cantango
Usage in a Rails 3 app
Insert into Gemfile
Run bundler to bundle gems in the app
The CanTango pattern is simple:
1. Return cached rules (if available)
2. Generate rules
3. Cache rules
1. Use cached rules and return if user has cached rules
2. Generate rules for Permits if ‘Permits engine’ is turned on
3. Generate rules for Permissions if ‘Permissions engine’ is turned on
4. Cache generated rules with unique key for current user
See CanTango Ability
Rails 3 configuration
Minimal role system requirements
CanTango requires that you have some kind of ‘role system’ in place (see Role system requirement)
Supported role systems
Currently the role system Troles is targeted, but any role system will do with a few minor patches on top
Permission rules can be defined in:
- Permission store
- Permit classes
Application configuration for CanTango
- Define roles that Users can have
- Define which roles are available
- Define a Permit for each role.
- For each Permit, define what Users with a role matching the permit can do
CanTango is integrated with CanCan REST links, letting you easily control which users have access to which models in your app.
The coming Rails 3 engine Dancing will include a full_config generator that you can use to configure your Rails app for devise, cancan, cantango and troles.
Permits can be defined for any of the following:
- Role groups
In addition you can also define licenses, that are sets of permit rules that can be reused in various role and role group permits.
You can use the Permits generator to generate your permits. All Permit classes should be placed in the app/permits folder of a Rails app.
See Role permits in the wiki.
See Account permits on the wiki
Permit for Role group
The Permits system uses some special permits System and Any, that can be configured for
advanced permission scenarios as described in the wiki.
See Licenses in the wiki.
See Advanced Permits
The gem comes with the following generators
- can_tango:role_permits – generate multiple permits
- can_tango:role_permit – generate a single permit
- can_tango:licenses – generate multiple licenses
- can_tango:license – generate a single license
You need help?
Please post ideas, questions etc. in the cantango group on Google.
Bugs, issues or feature request/ideas?
If you encounter bugs, raise an issue or:
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a
future version unintentionally.
- Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Kristian Mandrup. See LICENSE for details.