-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add documentation for #root #1794
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
Conversation
| ```ruby | ||
| def root | ||
| "posts" | ||
| end |
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.
@jimbeaudoin Thanks for this! mind taking a look at #1782 and see what you think? cc @beauby
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.
@bf4 I don't know about moving root at the adapter level. I think it's fine
here but it's my opinion.
Ex: if I have a model Api::V1:Post the root object name of the payload is
going to be api/v1/posts not posts. This is why I used this settings in
the serializer.
But this is the first time I separate my models like that (Api::V1::x). I
don't know if it's a good practice or not. This is a new experience on a
new API in development.
What you can do is merge this small documentation block to master because
this is how you can update root right now and it can help others on
v0.10.x.
And then update the doc in PR #1782 if she got merged. Like you, I think
it's going to need a deprecation warning before removing the old code.
On Thu, Jun 9, 2016 at 8:48 PM, Benjamin Fleischer <notifications@github.com
wrote:
In docs/general/serializers.md
#1794 (comment)
:@@ -217,7 +217,15 @@ The object being serialized.
#root
-PR please :)
+Allows you to change the root object name of the payload.
+
+e.g.
+
+```ruby
+def root
- "posts"
+end@jimbeaudoin https://github.com/jimbeaudoin Thanks for this! mind
taking a look at #1782
#1782 and see
what you think? cc @beauby https://github.com/beauby—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rails-api/active_model_serializers/pull/1794/files/8c00f3abd269d1116ace4ffb6c9b824eaa80de30#r66546734,
or mute the thread
https://github.com/notifications/unsubscribe/AG8xmBkgNaXRncHPB1pKkN-gZeUwBy68ks5qKLRMgaJpZM4IyU0-
.
Jimmy Beaudoin
email@jimmy-beaudoin.com
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.
@jimbeaudoin well, the thing is that root at this time is an options that is passed into the serializer. The method you would want to override is actually json_key or even set the type. (That's why I referenced the other pr which describes some of this in the diff). I'd certainly merge this change as an option to setting the resource root, but am hesitant for the documentation to advocate an unintended usage...
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.
@bf4 Ok I see, this PR can be closed then. json_key to the rescue! Thanks! :)
|
The submitter is fine with closing this one so maybe we should do that(?) |
|
Sure. It's really the wrong change. Thanks @jgrau |
Purpose
Add more documentation! :)
Changes
Add documentation for root in docs/general/serializers.md