-
Notifications
You must be signed in to change notification settings - Fork 529
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
JR not including type of polymorphic has_one when called to include it #509
Comments
Type is a reserved attribute name in JSON API. See http://jsonapi.org/format/#document-resource-object-fields. You should be getting a warning for that attribute. |
Ok, I've renamed the attribute |
After updating to 0.6.1, (which fixed my previous issue, thank you JR authors), I now have added the class Api::V1::NewRecordResource < JSONAPI::Resource
has_one :user
has_one :target, polymorphic: true
attributes :previous_value, :new_value, :message, :created_at
end And I get a new response, with the same empty "type" string: {
"data": {
"id": "1",
"type": "new-records",
"links": {
"self": "http://localhost:3000/api/v1/new-records/1"
},
"attributes": {
"previous-value": null,
"new-value": null,
"message": null,
"created-at": "2015-10-13T15:16:12.964Z",
"activity-type": "NewRecord"
},
"relationships": {
"user": {
"links": {
"self": "http://localhost:3000/api/v1/new-records/1/relationships/user",
"related": "http://localhost:3000/api/v1/new-records/1/user"
}
},
"target": {
"links": {
"self": "http://localhost:3000/api/v1/new-records/1/relationships/target",
"related": "http://localhost:3000/api/v1/new-records/1/target"
},
"data": {
"type": "", // <= should be "Facility"
"id": "239"
}
}
}
}
} Possibly helpful/related, {
"links": {
"self": "http://localhost:3000/api/v1/new-records/1/relationships/target",
"related": "http://localhost:3000/api/v1/new-records/1/target"
},
"data": {
"type": "",
"id": "239"
}
} and {
"data":null
} |
The rails repository can be found here: https://github.com/clov3rly/recruiting-resources-api/ |
The response from the server is missing the embedded target/data/type, or rather replacing it with the empty string...
http://localhost:3000/api/v1/activities/1?include=target,user
:The text was updated successfully, but these errors were encountered: