Skip to content
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

Support for {root: false} #13

Open
einarj opened this issue Oct 22, 2014 · 3 comments
Open

Support for {root: false} #13

einarj opened this issue Oct 22, 2014 · 3 comments

Comments

@einarj
Copy link

einarj commented Oct 22, 2014

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.

@danmcclain
Copy link
Contributor

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!

@BenMorganIO
Copy link

Currently experiencing this issue. 👍 If we can get it in.

@felixbuenemann
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants