Mongoid adapter for the CanCanCan authorisation library to automatically generate database queries from ability rules.
Ruby >= 2.0.0
ORJRuby >= 9.1
Mongoid >= 3.0
In your Gemfile
, insert the following line:
gem 'cancancan'
gem 'cancancan-mongoid'
This is it. You can now call accessible_by
on any Mongoid document (which is done automatically in the index action).
You can also use the query syntax that Mongoid provides when defining the abilities.
can :read, Article, :priority.lt => 5
This is all done through a Model Adapter. See that page for more information and how you can add your own.
If you find a bug please add an issue on GitHub or fork the project and send a pull request.
This gem uses appraisals to test the code base against multiple versions of Mongoid.
To start developing, run:
bundle install
appraisal install
You can then run all appraisal files (like CI does), with bundle exec appraisal rake
or just run a specific set bundle exec appraisal mongoid_6.1 rake
.