ams_endpoint.rb
class FoosController < ApplicationController | |
def index | |
@collection = Foo.all | |
render json: @collection, fields: params[:fields] | |
end | |
end | |
class FooSerializer < ActiveModel::Serializer | |
cache key: 'foo' | |
attributes( | |
:bar, | |
:baz, | |
:quz | |
) | |
end | |
GET /foos?fields=bar # => { data: [{ type: 'foos', id: 1, attributes: { bar: 'bar' } }, { type: 'foos', id: 2, attributes: { bar: 'bar' } }] } | |
GET /foos # => { data: [{ type: 'foos', id: 1, attributes: { bar: 'bar' } }, { type: 'foos', id: 2, attributes: { bar: 'bar' } }] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment