Skip to content


Subversion checkout URL

You can clone with
Download ZIP


accessible_by w/ mongoid criteria #611

brewster1134 opened this Issue · 2 comments

1 participant


EDITED to have a much simpler description of the problem :)

i have an ability defined with mongoid criteria, but it is not populating into the mongoid criteria selector attribute.

can :manage, Number, =>{ |p| }


-> Number.accessible_by(
=> #<Mongoid::Criteria
  selector: {},
  options:  {},
  class:    Number,
  embedded: false>

if i query mongoid directly with the same criteria

-> Number.where( =>{ |p| })
=> #<Mongoid::Criteria
  selector: {:issuer_id=>{"$in"=>[BSON::ObjectId('4f9ae0f1e1607c7a67000002')]}},
  options:  {},
  class:    Number,
  embedded: false>

the ability instance returns...

#<Ability:0x007f8c9d0c1030 @rules=[

i have tried defining my abilities a variety of ways

can :manage, Number, :issuer => { :owner_id => }
can :manage, Number, =>{ |p| }
can :manage, Number, :issuer_id => { "$in" =>{ |p| }}

using cancan (1.6.7) & mongoid (2.4.9)


solved it.{ |p| } was returning an array of BSON objects. i needed an array of strings.{ |p| } solved it. gah!

would a check for this make sense in the mongoid adapter?

@brewster1134 brewster1134 reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.