title: Pundit policy_scope with Grape api
body: <p>I am building API endpoints with <code>Grape</code>.</p>
  
  <p>I have below <code>scope</code>:</p>
  
  <pre><code>class JourneyPolicy &lt; ApplicationPolicy
  
    def create?
      user &amp;&amp; user.identt_id == record
    end
  
    class Scope
      attr_reader :user, :scope
  
      def initialize(user, scope)
        @user = user
        @scope = scope
      end
  
      def resolve
        scope.where(user_id: user.id).latest
      end
    end
  end
  </code></pre>
  
  <p>And now, I want to use this <code>policy_scope</code> in my grape resource, we can use <code>policy_scope(Journey)</code> in rails controller, but I can't make it working with grape endpoint:</p>
  
  <pre><code>class Journeys &lt; Grape::API
    resources :journeys do
      get do
        @journeys = policy_scope(Journey)
        present @journeys, with: Entities::Journey
      end
    end
  end
  </code></pre>
  
  <p>This is not working, and I am getting <code>NoMethodError</code> for <code>policy_scope</code>.</p>
  
  <p>I would like to use that grape policy and any help would be appreciated :)</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>I have below code which is working in grape endpoint to authorize resources like: </p>
  
  <pre><code>error!("Unauthorized Access!", 401) unless JourneyPolicy.new(journey, uid).create?
  </code></pre>
  
  <p>Thanks</p>