Search for nested json Rails files

Asked

Viewed 161 times

1

I have some files that are services, organs, units. The agencies have services and units. I, in the jsons I have, can return to the part where, for example: localhost/api/organs/.json. that it returns the services and units that the organ has. What I wish is that when I reach the point I have set out to be possible, using the id of a service or drive, I can access this service or drive.

json.array!(@organs) do |organ|
	json.id @organ.id.to_s
	json.unit do
		json.id organ.unit.id.to_s 
		json.name organ.unit.name
		json.address organ.organ.unit.address
		json.coordinates organ.organ.unit.coordinates
		json.schedules organ.unit.schedules
		json.phone organ.unit.phone
		json.email organ.unit.email
	end if organ.unit
	json.service @organ.service

  • Solved your doubt?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.