Created
June 4, 2015 20:00
-
-
Save kulte/c1bb978043650cdee5c7 to your computer and use it in GitHub Desktop.
ams_endpoint.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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