Rollable is a very old gem that should not be used in production. It is unmaintained and untested with Rails > 2.3. Also, the code is very crude and dodgy.
Rollable is a Rails gem that adds agnostic roles to your application. The core principle is that a role should not
be coupled to any object, but is nothing more than a relationship. Rollable does not define semantics, you can use
cancan or some similar gem to do just that.
Add to your gemfile
Rollable is ment to be easy and maintainable, with a minimal amount of configuration nescecary.
Setup the role model and migration, where is the model name you want to be able to have roles
rails generate rollable:setup
Just two lines!
In the model you defined during setup:
rollables model names, option hash
Currently, the available options are:
:roles => [Array of Strings] # Role names
:allow_nil => false # If true, you can create generic roles (like ‘admin’)
- Hardly any configuration
- Validates role names, role types by inclusion and user presence on Role (all dynamic)
- Much more!
We’ll call the model that can have roles users, for the sake of laziness.
Rollable provides helpers based on role names to check whether a user has a role on an object:
user.is_owner_of?(horse) # => true
You can also request all possible roles
You can set roles easily by using the helper
If you use nil roles, you can also do
Since 0.0.2 you can also do
And, to get all users with that role
- Its the first release, don’t whine.
- Role names can only be single words (so no underscores), but keep it simple, right?
Questions? Comments? Contribute? All welcome!
- Timon Vonk