Skip to content
EppO edited this page Aug 8, 2012 · 28 revisions

Frequently asked questions

When I start Rails using server, console, whatever, I get this error:

undefined local variable or method `rolify' for User:Class

If you are using Mongoid ORM, make sure you load rolify (using the rolify method) after Mongoid::Document include in the User class. For example:

class User
  include Mongoid::Document
  rolify
end

If you are using ActiveRecord, you should not get this error, please fill a bug

Is it possible to manage 2 sets : Role and AdminRole ?

If you have 2 different User classes, let's say User and AdminUser, yes it is. To make it work, you need 2 Role classes (Role and AdminRole), so 2 tables in the database (so 2 migration files if you use ActiveRecord). To make it easier, just run the generator twice:

  • rails g Rolify:role
  • rails g Rolify:role AdminRole AdminUser

In User class, you just have to put rolify method in it In AdminUser class, you would add: rolify :role_cname => "AdminRole" to make it work


Clone this wiki locally