mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Append an _id or _ids suffix to associations' keys. Embed objects in root according to their serializers' names.
An `_id` suffix will be appended to the name of HasOne associations, while `_ids` will be appended to the singularized name of HasMany associations. Association keys can still be overridden with the `key` option. Furthermore, objects embedded in the root are now by default named according to their serializer, instead of the key used for their associations.
This commit is contained in:
10
README.md
10
README.md
@@ -386,7 +386,7 @@ Now, any associations will be supplied as an Array of IDs:
|
||||
"id": 1,
|
||||
"title": "New post",
|
||||
"body": "A body!",
|
||||
"comments": [ 1, 2, 3 ]
|
||||
"comment_ids": [ 1, 2, 3 ]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -413,7 +413,7 @@ The JSON will look like this:
|
||||
"comments": [
|
||||
{ "id": 1, "body": "what a dumb post" }
|
||||
],
|
||||
"tags": [ 1, 2, 3 ]
|
||||
"tag_ids": [ 1, 2, 3 ]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -444,11 +444,11 @@ this:
|
||||
"id": 1,
|
||||
"title": "New post",
|
||||
"body": "A body!",
|
||||
"comments": [ 1, 2 ]
|
||||
"comment_ids": [ 1, 2 ]
|
||||
},
|
||||
"comments": [
|
||||
{ "id": 1, "body": "what a dumb post", "tags": [ 1, 2 ] },
|
||||
{ "id": 2, "body": "i liked it", "tags": [ 1, 3 ] },
|
||||
{ "id": 1, "body": "what a dumb post", "tag_ids": [ 1, 2 ] },
|
||||
{ "id": 2, "body": "i liked it", "tag_ids": [ 1, 3 ] },
|
||||
],
|
||||
"tags": [
|
||||
{ "id": 1, "name": "short" },
|
||||
|
||||
Reference in New Issue
Block a user