-
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
1506 document passing arbitrary options to serializer #1545
Merged
bf4
merged 7 commits into
rails-api:master
from
hiimtaylorjones:1506-document-passing-arbitrary-options-to-serializer
Mar 7, 2016
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5587699
rough draft
hiimtaylorjones 6a8da1f
adding ruby tag to code blocks
hiimtaylorjones e9f2596
addressing pull request comments
hiimtaylorjones da55cd1
addressing comments / concerns
hiimtaylorjones 32c6bcc
edits and rearranging logic
hiimtaylorjones 60a207b
wrong link
hiimtaylorjones 48f8a89
a little bit more trimming
hiimtaylorjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
adding ruby tag to code blocks
- Loading branch information
commit 6a8da1f6646d3bb10079876d395d9d6e4b08e3b9
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
Let's say you have a basic Post Controller: | ||
|
||
``` | ||
```ruby | ||
class PostController < ApplicationController | ||
def dashboard | ||
render json: @posts | ||
|
@@ -12,7 +12,7 @@ end | |
|
||
Odds are, your serializer will look something like this: | ||
|
||
``` | ||
```ruby | ||
class PostSerializer < ActiveModel::Serializer | ||
attributes :id, :title, :body | ||
end | ||
|
@@ -23,7 +23,7 @@ into the serializer. Here's what you would do: | |
|
||
### posts_controller.rb | ||
|
||
``` | ||
```ruby | ||
... | ||
def dashboard | ||
render json: @posts, user_id: 12 | ||
|
@@ -33,7 +33,7 @@ into the serializer. Here's what you would do: | |
|
||
### posts_serializer.rb | ||
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. Typo. Should be |
||
|
||
``` | ||
```ruby | ||
... | ||
def comments_by_me | ||
Comments.where(user_id: instance_options[:user_id], post_id: object.id) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't know what's your opinion on this but I usually find easier to easier to understand when having the full code snippet instead of just part of it. Also I usually tend to prefer having one snippet with comments to specify the filename instead of using h3 here. An example here would be:
Maybe that's just my opinion and might not be true for everyone so let me know what you guys think.
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.
I really don't mind that at all. Definitely could flow a bit better. Going to do an A / B comparison and see what's up.