diff --git a/docs/README.md b/docs/README.md index a05fdfb3..51c8c85f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,15 @@ This is the documentation of AMS, it's focused on the **0.10.x version.** - [How to add root key](howto/add_root_key.md) - [How to add pagination links](howto/add_pagination_links.md) - [Using AMS Outside Of Controllers](howto/outside_controller_use.md) -- [How to use JSON API with Ember](howto/ember-and-json-api.md) + +## Integrations +| Integration | Supported AMS versions | Gem name and/or link +|----|-----|---- +| Ember.js | 0.9.x | [active-model-adapter](https://github.com/ember-data/active-model-adapter) +| Ember.js | 0.10.x + | [docs/integrations/ember-and-json-api.md](integrations/ember-and-json-api.md) +| Grape | 0.10.x + | [#1258](https://github.com/rails-api/active_model_serializers/issues/1258) | +| Grape | 0.9.x | https://github.com/jrhe/grape-active_model_serializers/ | +| Sinatra | 0.9.x | https://github.com/SauloSilva/sinatra-active-model-serializers/ ## Getting Help diff --git a/docs/howto/ember-and-json-api.md b/docs/integrations/ember-and-json-api.md similarity index 83% rename from docs/howto/ember-and-json-api.md rename to docs/integrations/ember-and-json-api.md index b132aabf..cf2e52ae 100644 --- a/docs/howto/ember-and-json-api.md +++ b/docs/integrations/ember-and-json-api.md @@ -1,7 +1,8 @@ -# How to use JSON API Query Parameters with Ember +# Integrating with Ember and JSON API - [Preparation](./ember-and-json-api.md#preparation) - - [Adapter Changes](./ember-and-json-api.md#adapter-changes) + - [Server-Side Changes](./ember-and-json-api.md#server-side-changes) + - [Adapter Changes](./ember-and-json-api.md#adapter-changes) - [Serializer Changes](./ember-and-json-api.md#serializer-changes) - [Including Nested Resources](./ember-and-json-api.md#including-nested-resources) @@ -12,6 +13,21 @@ Note: This guide assumes that `ember-cli` is used for your ember app. The JSON API specification calls for hyphens for multi-word separators. AMS uses underscores. To solve this, in Ember, both the adapter and the serializer will need some modifications: +### Server-Side Changes + +there are multiple mimetypes for json that should all be parsed similarly, so +in `config/initializers/mime_types.rb`: +```ruby +api_mime_types = %W( + application/vnd.api+json + text/x-json + application/json +) + +Mime::Type.unregister :json +Mime::Type.register 'application/json', :json, api_mime_types +``` + ### Adapter Changes ```javascript @@ -34,6 +50,8 @@ export default DS.JSONAPIAdapter.extend({ // allows queries to be sent along with a findRecord // hopefully Ember / EmberData will soon have this built in + // ember-data issue tracked here: + // https://github.com/emberjs/data/issues/3596 urlForFindRecord(id, modelName, snapshot) { let url = this._super(...arguments); let query = Ember.get(snapshot, 'adapterOptions.query');