Closed aledalgrande closed 10 years ago
I was really confused as to why the role scopes weren't working or any helper method really: it's necessary to manually add the roles_mask field to the user table.
My definition:
class AdminUser < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me, :roles acts_as_user roles: [:contributor, :blogger, :producer, :admin] end
Example errors:
2.0.0-p0 :005 > AdminUser.admins NoMethodError: undefined method `admins' for #<Class:0x007f8f96372760>
2.0.0-p0 :002 > AdminUser.valid_roles => []
2.0.0-p0 :002 > AdminUser.first.roles = ['admin'] AdminUser Load (1.8ms) SELECT "admin_users".* FROM "admin_users" LIMIT 1 NoMethodError: undefined method `roles_mask=' for #<AdminUser:0x007fac0bfee480>
2.0.0-p0 :001 > AdminUser.with_any_role AdminUser Load (1.4ms) SELECT "admin_users".* FROM "admin_users" WHERE ("admin_users"."roles_mask" & 0 > 0) ActiveRecord::StatementInvalid: PG::Error: ERROR: column admin_users.roles_mask does not exist
Added missing info to the README.
I was really confused as to why the role scopes weren't working or any helper method really: it's necessary to manually add the roles_mask field to the user table.
My definition:
Example errors:
Added missing info to the README.