mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Add key option to serializer associations
This commit is contained in:
@@ -264,6 +264,12 @@ You may also use the `:serializer` option to specify a custom serializer class,
|
||||
has_many :comments, serializer: CommentPreviewSerializer
|
||||
```
|
||||
|
||||
And you can change the JSON key that the serializer should use for a particular association:
|
||||
|
||||
```ruby
|
||||
has_many :comments, key: :reviews
|
||||
```
|
||||
|
||||
The `url` declaration describes which named routes to use while generating URLs
|
||||
for your JSON. Not every adapter will require URLs.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user