Ruby on Railsを学んでいます。
私http://localhost:3000/locations.jsonの戻り値は次のとおりです。
[{
"name":"ABC",
"address":"xyz",
"latitude":12.3,
"longitude":14.5,
"url":"http://localhost:3000/locations/1.json"
}]
URL を解析せずlocations_controller.rbに JSON が を返すように を変更するにはどうすればよいですか?id
[{
"id":1,
"name":"ABC",
"address":"xyz",
"latitude":12.3,
"longitude":14.5,
"url":"http://localhost:3000/locations/1.json"
}]
私の現在locations_controller.rbにはこれが含まれています:
def index
puts "index"
@locations = Location.all
end
ありがとうございました。