Comments (9)
Hi @fran-worley. Can you post the exact arguments? Note also that the option is include
not included
:
http://www.rubydoc.info/gems/roar-jsonapi/Roar%2FJSON%2FJSONAPI%2FDocument:to_hash
from roar-jsonapi.
Yup, that was poor github issue writing on my part, my render call is pretty simple:
# r.params["include"] == 'feature-image'
sites = Site.all
representer = Site::FullRepresenter.for_collection.new(sites)
response.write(representer.to_json(include: r.params["include"]))
from roar-jsonapi.
@fran-worley if you're able to provide a reproduction (or at least the representers), that would help. Otherwise I'll try to reproduce this on the weekend.
from roar-jsonapi.
Is this enough info?
https://gist.github.com/fran-worley/39451042e02244d7efa9af3d9f952d58
from roar-jsonapi.
@fran-worley I believe this is an issue with hyphenation: feature-image
relationship name vs. feature_image
method name, although I'm surprised it isn't affecting single representers as well.
I would suspect that if you were to rename feature-image
to feature
then it would work.
In any case, this is definitely a bug.
from roar-jsonapi.
Hadn't thought of that, I'll run the same test with a non-hyphenated name and see what happens!
from roar-jsonapi.
I've got the same issue when passing in a fields
option into to_json
. I've checked both dasherised and underscored names and it makes no difference.
from roar-jsonapi.
Can confirm that relationships passed in via include:
don't work if they are hyphenated (like it would be for a JSONAPI request). We've got a "users" resource that has a "team-memberships" relationship on it. Passing in include=team_memberships
works, but include=team-memberships
doesn't.
I'll see if I can pin this down and send a PR, here's the workaround we're using for now:
normalized_include = (params[:include] || "").split(",").map(&:underscore)
render json: UserRepresenter.for_collection.prepare(users).to_json(include: normalized_include)
from roar-jsonapi.
Hi @rohitpaulk 🍻 thanks for posting your fix! The maintainer of this gem is presently lost without a trace, once he's back we might revisit this gem!
from roar-jsonapi.
Related Issues (20)
- [JSON-API] Nested polymorphic representation HOT 5
- JSON-API support for :extends/:decorator with has_one
- [JSON-API] Relationship links HOT 11
- JSON API dasherize property names HOT 4
- References represented inside of link block using JSONAPI implementation HOT 4
- JSON-API representer does not work with Roar::Client HOT 1
- Properties convert as camelize(:lower) HOT 6
- Representers: `defaults` block is lost in nested declarations HOT 3
- Collection representation HOT 8
- Update Operation with Roar JSONAPI representer forces contract to open up id HOT 1
- double included fields HOT 4
- Compound Documents not rendered per JSONAPI standard? HOT 2
- Performance issue when decorator files are loaded multiple times HOT 4
- Representer attributes with null values are excluded from resource document
- Should be able to return relationship links without including the related representer
- How to set the type of included items? HOT 5
- Using JSONAPI HOT 4
- [JSON-API] Rendering an empty relationship HOT 3
- [JSON-API] Recursive has_many :children (include tree) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roar-jsonapi.