-
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
Bug fix for ArraySerializer json_key #1007
Bug fix for ArraySerializer json_key #1007
Conversation
When the resource is a zero result query, i.e. post_comments = PostComment.where("1=0") the json_key will become 'postcomments' rather than 'post_comments'. Using 'underscore' instead of 'downcase' fixes the error.
Awesome @jiajiawang! |
Sure
|
test json key when resource is empty
Great! LGTM, I'm merging it. |
Bug fix for ArraySerializer json_key
@@ -38,6 +38,17 @@ def test_meta_and_meta_key_attr_readers | |||
assert_equal @serializer.meta, "the meta" | |||
assert_equal @serializer.meta_key, "the meta key" | |||
end | |||
|
|||
def test_json_key_when_resource_is_empty | |||
Array.class_eval do |
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.
❓
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 like it's trying to be a fake AR Relation
When the resource is a zero result query,
i.e. post_comments = PostComment.where("1=0")
the json_key will become 'postcomments' rather than 'post_comments'.
Using 'underscore' instead of 'downcase' fixes the error.