-
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
Add resource-level meta docs. Update top-level meta docs. #1566
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,8 +81,12 @@ PR please :) | |
|
||
#### meta | ||
|
||
If you want a `meta` attribute in your response, specify it in the `render` | ||
call: | ||
A `meta` member can be used to include non-standard meta-information. `meta` can | ||
be utilized in several levels in a response. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you saying you'd like this changed to |
||
|
||
##### Top-level | ||
|
||
To set top-level `meta` in a response, specify it in the `render` call. | ||
|
||
```ruby | ||
render json: @post, meta: { total: 10 } | ||
|
@@ -94,12 +98,33 @@ The key can be customized using `meta_key` option. | |
render json: @post, meta: { total: 10 }, meta_key: "custom_meta" | ||
``` | ||
|
||
`meta` will only be included in your response if you are using an Adapter that supports `root`, | ||
as JsonAPI and Json adapters, the default adapter (Attributes) doesn't have `root`. | ||
`meta` will only be included in your response if you are using an Adapter that | ||
supports `root`, e.g., `JsonApi` and `Json` adapters. The default adapter, | ||
`Attributes` does not have `root`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want to collaborate with #1557 in some way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My plan was to make minimal changes here so #1557 still has things that can be done. |
||
|
||
#### meta_key | ||
|
||
PR please :) | ||
##### Resource-level | ||
|
||
To set resource-level `meta` in a response, define meta in a serializer with one | ||
of the following methods: | ||
|
||
As a single, static string. | ||
|
||
```ruby | ||
meta stuff: 'value' | ||
``` | ||
|
||
As a block containing a Hash. | ||
|
||
```ruby | ||
meta do | ||
{ | ||
rating: 4, | ||
comments_count: object.comments.count | ||
} | ||
end | ||
``` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there something specific you're directing my attention here to do? |
||
|
||
#### 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.
s/non-standard/custom
(or something to that effect)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.
Sure, although that's copy from the JSON API docs.
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.
You're right. I saw that later :embarrassed:
On Wed, Mar 9, 2016 at 8:40 AM Ben Mills notifications@github.com wrote: