james2m / canard

Makes role based authorization in Rails really simple. Wraps CanCan and RoleModel up with a smattering of syntactic sugar, some generators and scopes.
MIT License
125 stars 28 forks source link

Add support for mongoid 4 #15

Closed ninetwentyfour closed 10 years ago

ninetwentyfour commented 10 years ago

There is a problem with the user scopes in mongoid 4.0.0.alpha2.

When trying to start rails or run tests with an app using 4.0.0.alpha2 and canard the following error is thrown.

Problem:
  Defining a scope of value #<Mongoid::Criteria:0x007fe4a48d3e30> on User is not allowed.
Summary:
  Scopes in Mongoid must be procs that wrap criteria objects.
Resolution:
  Change the scope to be a proc wrapped critera.

 Example:
   class Band
     include Mongoid::Document
     scope :inactive, ->{ where(active: false) }
   end

This should fix the issue. If you want to wait until 4.0 is out of beta to merge this, that's fine.