Support for {root: false}
einarj opened this issue · comments
First of all, thanks for an awesome project.
When I render with plain active model serializers with
render :json => @events, root: false
It produces an array of objects.
However when I put postgres_ext-serializers in place, it returns
{"events": [same array as before]}
In other words, the option of removing the root does not seem to be working.
Thanks for reporting this! This project is far from done at the moment, so this is one of the options yet to be implemented. I guess that is "by design" so far, but realistically, it just needs to be added in!
Currently experiencing this issue. 👍 If we can get it in.
This shouldn't be too hard to add for the embed :ids
case or if no associations are present. I looked at the original AMS implementation and it only support root: false
if sideloading is not used. Otherwise an error is raised:
ActiveModel::Serializer::IncludeError: Cannot serialize foos when FooSerializer does not have a root!
This can be worked around by forcibly excluding all embedded records using the include: []
option.
Supporting embed: :objects
would probably be much harder, because I think it can embed objects recursively, which would require quite some changes in the postgres code.