EppO/rolify — pull request #111 by amer (2012-11-09 23:56:07+00:00)
Title: Test cases for User#add_role method when useing Mongoid adapter and the resource is resourcifed and rolifed in the same time

Basically the problem happens when the method ```user.roles``` is called, and that happens when we try to add a new role, more specifically in ```lib/rolify/adapters/mongoid/role_adapter.rb```

```
def add(relation, role)
relation.roles << role
end
```

When you add ```resourcify``` and ```rolify``` for the same model basically you are doing something like

```
class User
include Mongoid::Document

has_many :roles
has_and_belongs_to_many :roles

field :name, type: String
end
```

And that seems to cause a great deal of confusion for our friend Mongoid. I think that Mongoid is defining a new method but with a wrong name which probably caused an infinite recursion and that's resulted in a ```SystemStackError: stack level too deep```.

I'm not sure but maybe this is a Mongoid bug, but for sure we can do something to work around it.

I hope this was useful.