Skip to content

Instantly share code, notes, and snippets.

@abhisek
Created April 17, 2017 08:24
Show Gist options
  • Save abhisek/3fd6e0521a85f18335a1ecdbfc4dc073 to your computer and use it in GitHub Desktop.
Save abhisek/3fd6e0521a85f18335a1ecdbfc4dc073 to your computer and use it in GitHub Desktop.
api-scoped-query
class Api::V1::ProjectsController < Api::V1::ApiController
before_filter :authenticate_api_user!
before_filter :load_customer!
def index
@projects = @customer.projects.order('created_at DESC')
render :json => @projects, :except => project_exclusions,
:methods => project_inclusions
end
protected
def load_customer!
@customer = ::Customer.find(params[:customer_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment