From 8df5b045f270ce502a0bd9f203c80ec5be64177e Mon Sep 17 00:00:00 2001 From: Kyle Shevlin Date: Mon, 13 Jun 2016 22:54:27 -0700 Subject: [PATCH] update integration documentation for ember and JSONAPI to include key_transform underscores to match the attribute and relationship underscore transformations --- docs/integrations/ember-and-json-api.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/integrations/ember-and-json-api.md b/docs/integrations/ember-and-json-api.md index bd4fa4c0..1024f396 100644 --- a/docs/integrations/ember-and-json-api.md +++ b/docs/integrations/ember-and-json-api.md @@ -17,8 +17,30 @@ To solve this, in Ember, both the adapter and the serializer will need some modi ### Server-Side Changes -there are multiple mimetypes for json that should all be parsed similarly, so +First, set the adapter type in an initializer file: + +```ruby +# config/initializers/ams_config.rb +ActiveModelSerializers.config.adapter = :json_api +``` + +or: + +```ruby +# config/initializers/ams_config.rb +ActiveModelSerializers.config.adapter = ActiveModelSerializers::Adapter::JsonApi +``` + +You will also want to set the `key_transform` to `:underscore` since you will adjust the attributes in your Ember serializer to use underscores instead of dashes later. + +```ruby +# config/initializers/ams_config.rb +ActiveModelSerializers.config.key_transform = :underscore +``` + +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