Search in json nested rails files

1

I have some files that are: services, organs, units. The organs have services and have units. I, in the jsons I have, can return to the part where, for example: localhost / api / organs / .json. That there it returns the services and the units that the organ possesses. What I want is that when I get to the point I've exposed it is possible, using the id of a service or drive, to 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
    
asked by anonymous 12.09.2016 / 20:39

0 answers