I'm retrieving all my items with a REST API call (get) and returning a json, this is the code in the controller:
class PeopleController < ApplicationController
def index
@people = Person.all
render json: @people
end
end
It's returning, but with a "data" field at the beginning:
{"data":
[
{"id":"1","type":"people","attributes": {"name":"survivorTest","age":"55"}},
{"id":"2","type":"people","attributes": {"name":"test666","age":"44"}},
{"id":"3","type":"people","attributes": {"name":"test666","age":"6666"}}
]
}
This is my route:
Rails.application.routes.draw do
resources :people
end
How can I return only the attributes from each row?