1
- # How to use JSON API Query Parameters with Ember
1
+ # Integrating with Ember and JSON API
2
2
3
3
- [ Preparation] ( ./ember-and-json-api.md#preparation )
4
- - [ Adapter Changes] ( ./ember-and-json-api.md#adapter-changes )
4
+ - [ Server-Side Changes] ( ./ember-and-json-api.md#server-side-changes )
5
+ - [ Adapter Changes] ( ./ember-and-json-api.md#adapter-changes )
5
6
- [ Serializer Changes] ( ./ember-and-json-api.md#serializer-changes )
6
7
- [ Including Nested Resources] ( ./ember-and-json-api.md#including-nested-resources )
7
8
@@ -12,6 +13,21 @@ Note: This guide assumes that `ember-cli` is used for your ember app.
12
13
The JSON API specification calls for hyphens for multi-word separators. AMS uses underscores.
13
14
To solve this, in Ember, both the adapter and the serializer will need some modifications:
14
15
16
+ ### Server-Side Changes
17
+
18
+ there are multiple mimetypes for json that should all be parsed similarly, so
19
+ in ` config/initializers/mime_types.rb ` :
20
+ ``` ruby
21
+ api_mime_types = %W(
22
+ application/vnd.api+json
23
+ text/x-json
24
+ application/json
25
+ )
26
+
27
+ Mime ::Type .unregister :json
28
+ Mime ::Type .register ' application/json' , :json , api_mime_types
29
+ ```
30
+
15
31
### Adapter Changes
16
32
17
33
``` javascript
@@ -34,6 +50,8 @@ export default DS.JSONAPIAdapter.extend({
34
50
35
51
// allows queries to be sent along with a findRecord
36
52
// hopefully Ember / EmberData will soon have this built in
53
+ // ember-data issue tracked here:
54
+ // https://github.com/emberjs/data/issues/3596
37
55
urlForFindRecord (id , modelName , snapshot ) {
38
56
let url = this ._super (... arguments );
39
57
let query = Ember .get (snapshot, ' adapterOptions.query' );
0 commit comments