Skip to content

Instantly share code, notes, and snippets.

@quicksnap
Created December 14, 2013 21:03
Show Gist options
  • Select an option

  • Save quicksnap/7964867 to your computer and use it in GitHub Desktop.

Select an option

Save quicksnap/7964867 to your computer and use it in GitHub Desktop.
# This could be improved i'm sure..
class Api::V1::CurrenciesController < ApplicationController
respond_to :json
def index
render(default_serializer Currency.all)
end
def show
render( default_serializer Currency.find(params[:id]) )
end
private
def default_serializer records
{ json: records, each_serializer: Api::V1::CurrencySerializer }
end
end
class Api::V1::CurrencySerializer < ActiveModel::Serializer
attributes :id, :country, :rate
end
App.Currency = DS.Model.extend
country: DS.attr()
rate: DS.attr()
App.Store = DS.Store.extend
adapter: DS.ActiveModelAdapter.extend
namespace: 'api/v1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment