DEPRECATED: see comment below
Just updated an ember-cli/rails pair of example apps to use json-api and thought i’d write some notes to help out anyone doing same.
The Example Apps:
The important thing here was updating to a version of active-model-serializer which uses json-api 1.0. I used 0.10.rc2.
You will need to set AMS to use json-api in an initializer.
ActiveModel::Serializer.config.adapter = :json_api
If you’re upgrading from 0.8 or 0.9 you will have to make other changes. There are a few here, though a more complex object model will probably need more:
On the Ember side:
Upgrade ember/ember-data to 1.13.x
Have your serializer to extend
isNewSerializerAPIto true. See here.
This flag is going away at some point, but if you forget it now, your serializer won’t be able to parse data in json api format, so while you’ll see the data coming over, it won’t get pushed into the store.
- Have your serializer to extend
JSONAPIAdapterand convert from dashes on Ember side to underscores on the Rails side. See
So not too complex, but hopefully save you from staring at your Rails routes file before you realize you need underscores not dashes, etc.