I managed to use Pundit for actions with name controllers, regardless of the model, using this:
In my / private / scrapers _controller.rb I have
module Private class ScrapersController < Private::PrivateApplicationController
And then in the policy / private / scrapers _policy.rb
class Private::ScrapersPolicy < ApplicationPolicy def index? return true if user.has_role?(:super_admin) return false end end
This will prevent any user who is not: super_admin from visiting the scrapers # index or any other action in the controller
To ban only the index explicitly, you can use:
before_action { authorize [:private, :scrapers], :index? }
luigi7up
source share