When I'm trying to query the role of a user object, I get an undefined method error. For example:
>> u.roles = [:admin, :depthead]
=> [:admin, :depthead]
>> u.save
=> true
>> u
=> #<User @id=1 @name="depthead1" @password="pass" @roles_mask="3"
>> u.roles
NoMethodError: undefined method `&' for "3":String
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `roles'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `reject'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `roles'
from (irb):11
>> u.has_role? :admin
NoMethodError: undefined method `&' for "3":String
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `roles'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `reject'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:11:in `roles'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:42:in `has_role?'
from (irb):12:in `any?'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:42:in `each'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:42:in `any?'
from /var/lib/gems/1.8/gems/role_model-0.6.0/lib/role_model/implementation.rb:42:in `has_role?'
from (irb):12
No matter what I do, I keep getting the same error. Can you help me out?
Hi Martin,
When I'm trying to query the role of a user object, I get an
undefined method
error. For example:No matter what I do, I keep getting the same error. Can you help me out?
Thanks, Abhas.