-
Notifications
You must be signed in to change notification settings - Fork 108
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
.represent() does not work with collections and JSON API #187
Comments
When you say "JSON API", do you mean the |
I mean the JSONAPI module. |
It's not even released yet 😁 haha! Is everything else working as expected? I will get back to the Roar 1.1 release, soon. Why is this posted on Representable, then, and not Roar, NILS? |
Damn, it's unreleased? That explains the next 3 issues in ran into. I didn't know whether the problem was in trailblazer, roar, representable or the docs -_- |
I need the feedback, man, I can't just magically find out what's not working in the current version! 😉 |
I'm in the chat. |
This is an issue with Trailblazer 1.1.x (not sure if Trailblazer 2.0 is affected) and not Representable/ROAR JSON API. The Either of the the following should work: Author::Representer::Index.represent(Author.all.to_a).to_json
Author::Representer::Index.represent(Author.all, ActiveRecord::Relation).to_json |
I'm trying to use Trailblazer to create a JSON API backend. Unfortunately, I can't get collections to work at all. This might be a mistake on my part, but I think I've tracked it down representable (but I'm not 100% sure).
What it boils down to is that
.represent()
does not work in JSON API when it's handed a collection.This works:
Author::Representer::Index.for_collection.new(Author.all).to_json
This does not work:
Author::Representer::Index.represent(Author.all).to_json
I think that should work, right?
I have created a very simple Rails application to demonstrate:
https://github.com/promisedlandt/trailblazerjsonapi
The text was updated successfully, but these errors were encountered: