Skip to content

Commit 88367da

Browse files
mrpinskybf4
authored andcommitted
Add warnings about global adapter config to docs (#2176)
1 parent 4d7c245 commit 88367da

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Fixes:
2020

2121
Misc:
2222

23+
- #2176 Documentation for global adapter config (@mrpinsky)
24+
2325
### [v0.10.6 (2017-05-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.5...v0.10.6)
2426

2527
Fixes:

docs/general/adapters.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ The `Attributes` adapter does not include a root key. It is just the serialized
3636

3737
Use either the `JSON` or `JSON API` adapters if you want the response document to have a root key.
3838

39+
***IMPORTANT***: Adapter configuration has *no effect* on a serializer instance
40+
being used directly. That is, `UserSerializer.new(user).as_json` will *always*
41+
behave as if the adapter were the 'Attributes' adapter. See [Outside Controller
42+
Usage](../howto/outside_controller_use.md) for more details on recommended
43+
usage.
44+
3945
## Built in Adapters
4046

4147
### Attributes - Default

docs/howto/add_root_key.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ In order to add the root key you need to use the ```JSON``` Adapter, you can cha
1818
ActiveModelSerializers.config.adapter = :json
1919
```
2020

21+
Note that adapter configuration has no effect on a serializer that is called
22+
directly, e.g. in a serializer unit test. Instead, something like
23+
`UserSerializer.new(user).as_json` will *always* behave as if the adapter were
24+
the 'Attributes' adapter. See [Outside Controller
25+
Usage](../howto/outside_controller_use.md) for more details on recommended
26+
usage.
27+
2128
You can also specify a class as adapter, as long as it complies with the ActiveModelSerializers adapters interface.
2229
It will add the root key to all your serialized endpoints.
2330

0 commit comments

Comments
 (0)