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

Links on items gives unknown method #4

Closed
philsturgeon opened this issue Nov 13, 2018 · 3 comments
Closed

Links on items gives unknown method #4

philsturgeon opened this issue Nov 13, 2018 · 3 comments

Comments

@philsturgeon
Copy link

I have a basic collection, and each item has links:

{
  "data": [
    {
      "type": "thing",
      "id": "123",
      "links": {
        "foo": "https://example/foo",
        "bar": "https://example/bar"
      },
      "attributes": {
          "thing": "yep"
        }
      }
    },
    ....
}

Following your instructions, I would expect to be able to do this:

response = JSON::Api::Vanilla.parse(json)
things = response.data

things.first.links # { "foo": "https://example/foo", "bar": "https://example/bar"} 

The actual result is:

*** NoMethodError Exception: undefined method `links' for #<#Class:0x00007fdb9783a7f0:0x00007fdb97839148>

Any suggestions?

@hovancik
Copy link

This might be the problem, but I guess further debugging is needed: https://github.com/trainline/json-api-vanilla/blob/master/lib/json-api-vanilla/parser.rb#L52

@Tolsee
Copy link

Tolsee commented Feb 7, 2020

@philsturgeon Does not the links have special meaning in JSON Api specification?

@philsturgeon
Copy link
Author

@Tolsee yes links is a thing and I was trying to access it. I no longer use this tool so cannot provide anymore information.

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

No branches or pull requests

3 participants