Skip to content

Commit 867d36a

Browse files
committed
updating readme and changelog
1 parent 61ac3ad commit 867d36a

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
### 0.10.0
22

3+
* adds adapters pattern
34
* adds support for `meta` and `meta_key` [@kurko]
4-
* adds method to override association [adcb99e, @kurko]
5+
* adds method to override association [@kurko]
56
* adds `has_one` attribute for backwards compatibility [@ggordon]
6-
* updates JSON API support to RC3 [@mateomurphy]
7+
* adds JSON API support 1.0 [@benedikt]
78
* adds fragment cache support [@joaomdmoura]
8-
* adds cache support to attributes and associations [@joaomdmoura]
9+
* adds cache support to attributes and associations [@joaomdmoura]
10+
* uses model name to determine the type [@lsylvester]
11+
* remove root key option and split JSON adapter [@joaomdmoura]
12+
* adds FlattenJSON as default adapter [@joaomdmoura]

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AMS does this through two components: **serializers** and **adapters**.
88
Serializers describe _which_ attributes and relationships should be serialized.
99
Adapters describe _how_ attributes and relationships should be serialized.
1010

11-
By default AMS will use the **Json Adapter**. But we strongly advise you to use JsonApi Adapter that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
11+
By default AMS will use the **Flatten Json Adapter**. But we strongly advise you to use **JsonApi Adapter** that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
1212
Check how to change the adapter in the sections bellow.
1313

1414
# RELEASE CANDIDATE, PLEASE READ
@@ -66,6 +66,12 @@ ActiveModel::Serializer.config.adapter = :json_api
6666
You won't need to implement an adapter unless you wish to use a new format or
6767
media type with AMS.
6868

69+
If you want to have a root key on your responses you should use the Json adapter, instead of the default FlattenJson:
70+
71+
```ruby
72+
ActiveModel::Serializer.config.adapter = :json
73+
```
74+
6975
If you would like the key in the outputted JSON to be different from its name in ActiveRecord, you can use the :key option to customize it:
7076

7177
```ruby
@@ -130,17 +136,7 @@ The key can be customized using `meta_key` option.
130136
render json: @post, meta: { total: 10 }, meta_key: "custom_meta"
131137
```
132138

133-
`meta` will only be included in your response if there's a root. For instance,
134-
it won't be included in array responses.
135-
136-
### Root key
137-
138-
If you want to define a custom root for your response, specify it in the `render`
139-
call:
140-
141-
```ruby
142-
render json: @post, root: "articles"
143-
```
139+
`meta` will only be included in your response if you are using an Adapter that supports `root`, as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.
144140

145141
### Overriding association methods
146142

@@ -176,9 +172,19 @@ end
176172

177173
### Built in Adapters
178174

175+
#### FlattenJSON
176+
177+
It's the default adapter, it generates a json response without a root key.
178+
Doesn't follow any specifc convention.
179+
180+
#### JSON
181+
182+
It also generates a json response but always with a root key. The root key **can't be overridden**, and will be automatically defined accordingly with the objects being serialized.
183+
Doesn't follow any specifc convention.
184+
179185
#### JSONAPI
180186

181-
This adapter follows RC4 of the format specified in
187+
This adapter follows 1.0 of the format specified in
182188
[jsonapi.org/format](http://jsonapi.org/format). It will include the associated
183189
resources in the `"included"` member when the resource names are included in the
184190
`include` option.

0 commit comments

Comments
 (0)