I am trying to create a policy so that only admins can acces a page. I've already managed to get pundit to work in another controller, but for some reason this policy wont work.
I've created a controller: users_controller.rb which is as follows:
def index
@user = current_user
authorize @user
end
end
I've created a Policy user_policy.rb which is:
def initialize(current_user, record)
@user = current_user
@record = record
end
def index?
@user.admin?
end
end
Any idea's what's going wrong?
I messed up, it routes to the users page, not an index.
Problem solved by changing
def index
to
def users
And do the same for the policy method