I have a web application in ruby on rails with devise as the authentication and pundit as the authorization.
I have a model user
with an integer role
attribute with values 0, 1, 2, for visitor
, vip
, and admin
respectively. I also have a scaffold, say Page
that I want just vip
and admin
to have access to and not visitor
users.
In page_policy.rb I have
def index?
current_user.vip? or current_user.admin?
end
and in pages_controller.rb I have a line authorize current_user
.
Although I have given access to vip
but it is available just for admin
user. Where have I been wrong with the code?
Thank you