-
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
Documentation for serializing resources without render #1139
Documentation for serializing resources without render #1139
Conversation
I like this. good work! |
the resource you want to be serialized and call `.serializable_hash`. | ||
|
||
```ruby | ||
def create |
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.
for the sake of readme length, do you think this should be simplified?
having context is nice though.
@joaomdmoura, what are your thoughts?
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.
Yea initially I had it a bit shorter
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.
@NullVoxPopuli do you mean the code example or the text? Or both? :)
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.
just the code example. the text is great! :)
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.
How about?
def create
@message = current_user.messages.create!(message_params)
MessageCreationWorker.perform(serialized_message)
head 204
end
def serialized_message
ActiveModel::SerializableResource.new(@message).serializable_hash
end
Less verbose and still has some contextual meaning
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.
that looks great!
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.
💥
looks good! |
Documentation for serializing resources without render
@NullVoxPopuli cheers that was superfast! ❤️ |
```ruby | ||
def create | ||
@message = current_user.messages.create!(message_params) | ||
MessageCreationWorker.perform(serialized_message) |
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.
Indentation
👍 |
I am trying this and I am getting |
@Awatatah That's because you presumably have a typo |
#1101