-
Notifications
You must be signed in to change notification settings - Fork 405
merlinvn edited this page Apr 25, 2012
·
28 revisions
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
extend Rolify
rolify
end
If you are using ActiveRecord, you should not get this error, please fill a bug
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