Bug fix for ArraySerializer json_key

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.
This commit is contained in:
Jiajia Wang 2015-07-15 10:11:06 +10:00
parent 954e4c51fe
commit 7faa5e8e2e

View File

@ -29,7 +29,7 @@ module ActiveModel
if @objects.first if @objects.first
@objects.first.json_key.pluralize @objects.first.json_key.pluralize
else else
@resource.name.downcase.pluralize if @resource.try(:name) @resource.name.underscore.pluralize if @resource.try(:name)
end end
end end