-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Documentation on Serializers and Rendering #2104
Conversation
@cassidycodes, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bf4, @remear and @koryteg to be potential reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for this! some small changes.
docs/general/rendering.md
Outdated
|
||
```ruby | ||
@post = Post.first | ||
render json: @post, serializer: SpecialPostSerializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please amend to show that you explicit serializer for a single resource can be specified by the serializer
option, and for a collection of all the same resource by each_serializer
. (Unfortunately,) when rending a collection, like an index action, serializer
refers to the collection serializer.
@@ -382,11 +382,26 @@ The serialized value for a given key. e.g. `read_attribute_for_serialization(:ti | |||
|
|||
#### #links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra #
in front of links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you man that #### #links
should be #### links
? Many h4
headers in this document have a #
as part of the text. I believe this is to indicate that they are instance methods. Would you like me to remove all of them? e.g. ln 238, ln 252
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're right about instance methods. Code blindness...
@bf4 Are these failing checks normal? |
@cassidycodes code, no, the failures are new.. not sure where
is coming from, but I'm guessing it's from grape and I'm thinking active_model_serializers-grape should be in its own repo? |
@bf4 I've squashed my commits and pushed again. Maybe those failures will mysteriously disappear too? If not I can try look into it. |
- Updating general/serializers.md - Updating docs/general/rendering.md - adding to changelog - Updating rendering.md to indicate that `each_serializer` must be used on a collection - updating my handle in previous changelog entry
@bf4 This branch is up-to-date now and should be ready for a merge. |
@@ -79,7 +80,7 @@ Misc: | |||
|
|||
- [#1878](https://github.com/rails-api/active_model_serializers/pull/1878) Cache key generation for serializers now uses `ActiveSupport::Cache.expand_cache_key` instead of `Array#join` by default and is also overridable. This change should be backward-compatible. (@markiz) | |||
|
|||
- [#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@ScottKbka) | |||
- [#1799](https://github.com/rails-api/active_model_serializers/pull/1799) Add documentation for setting the adapter. (@cassidycodes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you change your username? strange that this would be wrong.
Purpose
Complete documentation where the text 'PR Please :)' was.
Changes
Caveats
I wasn't sure what the best practice was with a few of the methods on rendering.md. The documentation for these options seems to exist elsewhere, so I just linked to it.
Related GitHub issues
Additional helpful information