rubytij/usergroup — pull request #52 by EnriqueVidal (2012-09-16 10:28:46+00:00)
Title: Make users <-> roles a hmt association

`acl9` uses `has_and_belongs_to_many` for the many to many relationship, which poses some problems:

* Join table can only have foreign keys
* There is no join model
* The lack of join model mean that we can't create scopes, or even make a relationship with more entities.

Fortunately since rails 3.0, associations are more powerful than in 2.3, and since the `acl9` code uses the association all the time, we just do the adjustment on the existing tables and create our own join model, we give `acl9` what it needs, but we override `acl9` association with our own.

The result is that all 3 points above get solved and our relationship between the models now looks like this:

users <-> enrollments <-> roles

And we can add any needed logic to enrollments in the future.

This commit also does some mayor performance improvements on roles (missing indices).