I have tree models: Tours, buses and locations
Tour have more buses, buses more locations.
I want to return json object with buses last locations for some tour.
Pseudo example:
BUSES
BUS1
last_location
/BUS1
BUS2
last_location
/BUS2
BUS3
last_locaiton
/BUS3
/BUSES
tour.buses will give me buses for that tour, and bus.locations.last latest location.
I know that is no since fiction, but I don’t know how to pack this in one json object to return it 😐
You could do it like this:
And then send
both_piecesback as JSON. Then the client would get one JSON object with thetourandlast_locationobjects inside it.