ruby on rails 4 - Rolify has_role? returning true after remove_role -



ruby on rails 4 - Rolify has_role? returning true after remove_role -

i following

user1 = user.find(1) user2 = user.find(2)

add role users

user1.add_role :teacher user2.add_role :teacher user1.has_role? :teacher >> true user2.has_role? :teacher >> true

delete role specific user

user1.remove_role :teacher user1.has_role? :teacher >> false user2.has_role? :teacher >> true

i having problem because currently

user1.has_role? :teacher

is returning true after remove. when user1.roles returns empty array expected , has_any_roles? returns false expected. why returning true after role removed?

you need reload user before checking if has role again

user1.remove_role :teacher user1.reload user1.has_role? :teacher

ruby-on-rails-4 devise cancan rolify pundit

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -