You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe I'm not understanding how jsonapi-utils/jsonapi-resource works, but I have a OrderResource and a OrderListResource (which is a simplified version of OrderResource). I am trying to render OrderListResource, but have the type value be order. Currently, it's setting it to order_list. Here's the render statement:
module Api
module V2
class OrderListResource < JSONAPI::Resource
attribute :status_name
end
end
end
Response
{
"data": [
{
"id": "1",
"type": "order_lists", # <-- wrong, should be "order"
"links": {
"self": "http://localhost:3001/api/v2/order_lists/1" # <-- wrong, should be order/1
},
"attributes": {
"status_name": "some_status"
}
},
{
"id": "2",
"type": "order_lists", # <-- wrong, should be "order"
"links": {
"self": "http://localhost:3001/api/v2/order_lists/2" # <-- wrong, should be order/2
},
"attributes": {
"status_name": "some_other_status"
}
}
]
}
EDIT:
I'm not sure if this is the proper solution, or if I'm using jsonapi-resource incorrectly, but I fixed it by adding the following to OrderListResource:
def self.name
'Order'
end
def self._type
'order'
end
The text was updated successfully, but these errors were encountered:
☝️ That's the answer I would bring up to you, as you mentioned it fixes the issue but I'm also not sure whether it's the proper way of doing so. Unfortunately JR's doc/issues are not clear around this case.
Maybe I'm not understanding how jsonapi-utils/jsonapi-resource works, but I have a
OrderResource
and aOrderListResource
(which is a simplified version ofOrderResource
). I am trying to renderOrderListResource
, but have thetype
value beorder
. Currently, it's setting it toorder_list
. Here's the render statement:jsonapi_render json: Order.last(2), options: { resource: Api::V2::OrderListResource }
OrderListResource
Response
EDIT:
I'm not sure if this is the proper solution, or if I'm using jsonapi-resource incorrectly, but I fixed it by adding the following to
OrderListResource
:The text was updated successfully, but these errors were encountered: