GithubHelp home page GithubHelp logo

Comments (9)

myabc avatar myabc commented on July 2, 2024

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.

fran-worley avatar fran-worley commented on July 2, 2024

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.

myabc avatar myabc commented on July 2, 2024

@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.

fran-worley avatar fran-worley commented on July 2, 2024

Is this enough info?
https://gist.github.com/fran-worley/39451042e02244d7efa9af3d9f952d58

from roar-jsonapi.

myabc avatar myabc commented on July 2, 2024

@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.

fran-worley avatar fran-worley commented on July 2, 2024

Hadn't thought of that, I'll run the same test with a non-hyphenated name and see what happens!

from roar-jsonapi.

fran-worley avatar fran-worley commented on July 2, 2024

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.

rohitpaulk avatar rohitpaulk commented on July 2, 2024

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.

apotonick avatar apotonick commented on July 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.