I want to skip the policy_scope requirement fro Pundit on one controller (home). I have 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? Any thoughts or suggestions?
I accomplished this by adding a skip_after_action to the home controller:
class HomeController < ApplicationController
skip_after_action :verify_policy_scoped, :only => :index
end
Since version 1.0.0 you can use skip_policy_scope
in a controller action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With