Skip to content
Snippets Groups Projects
Commit f759ab7e authored by Mani Tadayon's avatar Mani Tadayon
Browse files

Automatically add `accessible_by` to Mongoid Documents to match CanCan...

Automatically add `accessible_by` to Mongoid Documents to match CanCan behavior for ActiveRecord and DataMapper.

Previously, CanCan::ModelAdditions had to be included in each and every Mongoid document separately. Also removed manual include of CanCan::ModelAdditions from Mongoid documents in Mongoid adapter specs.
parent 6ccb4dd6
No related branches found
No related tags found
No related merge requests found
......@@ -51,3 +51,8 @@ module CanCan
alias_method :matches_conditions_hash?, :matches_conditions_hash_with_mongoid_subject?
end
end
# simplest way to add `accessible_by` to all Mongoid Documents
module Mongoid::Document::ClassMethods
include CanCan::ModelAdditions::ClassMethods
end
\ No newline at end of file
......@@ -3,14 +3,12 @@ if ENV["MODEL_ADAPTER"] == "mongoid"
class MongoidCategory
include Mongoid::Document
include CanCan::ModelAdditions
references_many :mongoid_projects
end
class MongoidProject
include Mongoid::Document
include CanCan::ModelAdditions
referenced_in :mongoid_category
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment