you don't seem to define @location
in the code you have posted.
you should iterate over your locations, jbuilder lets you do it for example like this:
Jbuilder.encode do |json|
json.locations @locations do |location|
json.id location.id
json.name location.name
end
end
see the docs if you want a flat array instead.