mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Unsuffixed association keys doc
This commit is contained in:
parent
4ac07de799
commit
226cbc4160
12
README.md
12
README.md
@ -236,6 +236,18 @@ end
|
||||
BlogSerializer.new(object, key_format: :lower_camel)
|
||||
```
|
||||
|
||||
## Changing the default association key type
|
||||
|
||||
You can specify that serializers use unsuffixed names as association keys by default.
|
||||
|
||||
`````ruby
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
config.default_key_type = :name
|
||||
end
|
||||
````
|
||||
|
||||
This will build association keys like `comments` or `author` instead of `comment_ids` or `author_id`.
|
||||
|
||||
## Getting the old version
|
||||
|
||||
If you find that your project is already relying on the old rails to_json
|
||||
|
||||
Loading…
Reference in New Issue
Block a user