2

I'm mounting Grape in my Rails project to build a RESTful API.

Web applications application controller runs verify_authorized after every action.

class ApplicationController < ActionController::Base
  include Pundit

  protect_from_forgery with: :exception

  after_action :verify_authorized,
           except: :index,
           unless: :devise_controller?
end

How we can use same after_action :verify_authorized in grape defaults.rb

I tried by including Pundit in defaults.rb and added method as

module Defaults
  extend ActiveSupport::Concern
  include Pundit
  before { verify_authorized }
end

But it throws undefined method error.

Can anyone please suggest how to call verify_authorized method of Pundit gem after every API call.

Thanks in advance.

Akash Kinwad
  • 704
  • 2
  • 7
  • 22

0 Answers0