0
I have an API that has the data in the following format:
[
{
"id": 1,
"vehicle": "350",
"code": "350",
"delivery_date": "2019-07-26T00:00:00.000Z",
"created_at": "2019-08-07T17:00:37.000Z",
"updated_at": "2019-08-07T17:00:37.000Z"
},
{
"id": 2,
"vehicle": "364",
"code": "364",
"delivery_date": "2019-07-26T00:00:00.000Z",
"created_at": "2019-08-07T17:00:37.000Z",
"updated_at": "2019-08-07T17:00:37.000Z"
},
{
"id": 3,
"vehicle": "1305",
"code": "1305",
"delivery_date": "2019-07-26T00:00:00.000Z",
"created_at": "2019-08-07T17:00:37.000Z",
"updated_at": "2019-08-07T17:00:37.000Z"
},
]
The point is that because of (I believe) the " [ ] " url/api/loads/list/1
just how do I change this output?
@loads = Load.all
render json: @loads, status: 200
That’s actually what I have.
The output is so pq Load.all returns a list of "load", if you want to return only one element you have to find
render json: Load.find(params[:id]), status: 200
– Felipe Bergamo