Skip mandate scope on one controller

I want to skip the policy_scope requirement for Pundit on one controller (home). I've tried this:

 class ApplicationController < ActionController::Base
  include Pundit
  after_action :verify_authorized, :except => :index, unless: :devise_controller?
  after_action :verify_policy_scoped, :only => :index, unless: controller.controller_name == "home"
 end

 class HomeController < ApplicationController
   def index
     redirect_to (new_user_session_path) unless user_signed_in?
     if user_signed_in?
       @user=current_user
     end
    end
  end

      

But I don't think the controller is defined yet or something else? Any thoughts or suggestions?

+3


source to share


1 answer


I did this by adding skip_after_action to my home controller:



class HomeController < ApplicationController
  skip_after_action :verify_policy_scoped, :only => :index
end

      

+4


source







All Articles