ruby-on-railsdevisepundit

skip authorization for specific controllers using pundit in rails 4


I am using rails 4, devise for authentication and Pundit for authorization. I have restricted my application to check for authorization on every controller by below code.

class ApplicationController < ActionController::Base
  include Pundit
  after_action :verify_authorized
  #.....
end

However, i want to skip authorization for two specific controllers in my application (they are open to public, users do not need to sign in). How can i achieve it without removing verify_authorized in ApplicationController ?


Solution

  • skip_after_action :verify_authorized