mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Merge pull request #1312 from NullVoxPopuli/integration-docs
[DOCS] begin integration docs
This commit is contained in:
commit
5301112c27
@ -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 root key](howto/add_root_key.md)
|
||||||
- [How to add pagination links](howto/add_pagination_links.md)
|
- [How to add pagination links](howto/add_pagination_links.md)
|
||||||
- [Using AMS Outside Of Controllers](howto/outside_controller_use.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
|
## Getting Help
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
- [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)
|
- [Serializer Changes](./ember-and-json-api.md#serializer-changes)
|
||||||
- [Including Nested Resources](./ember-and-json-api.md#including-nested-resources)
|
- [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.
|
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:
|
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
|
### Adapter Changes
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -34,6 +50,8 @@ export default DS.JSONAPIAdapter.extend({
|
|||||||
|
|
||||||
// allows queries to be sent along with a findRecord
|
// allows queries to be sent along with a findRecord
|
||||||
// hopefully Ember / EmberData will soon have this built in
|
// 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) {
|
urlForFindRecord(id, modelName, snapshot) {
|
||||||
let url = this._super(...arguments);
|
let url = this._super(...arguments);
|
||||||
let query = Ember.get(snapshot, 'adapterOptions.query');
|
let query = Ember.get(snapshot, 'adapterOptions.query');
|
||||||
Loading…
Reference in New Issue
Block a user