skip authorization for specific controllers using pundit in rails 4

skip_after_action :verify_authorized


I'm working with Rails 5 and I wanted to skip authorization in just one action but not the whole controller. So, what you can do according to the documentation is to use skip_authorization feature in the controller action as shown below:

class Admin::DashboardController < Admin::BaseController
    def index
        @organizers = Organizer.count
        @sponsors = Sponsor.count
        @brochures = Brochure.count

        skip_authorization
    end

    def sponsors_approve
        # some statements...
    end

    def organizers_approve
        # some statements...
    end
end

In this controller the only one action to be skipped is index, the other ones must be authorized.

I hope it could be useful for somebody else.