heylium-webapp/app/controllers/balloons_controller.rb
2016-11-08 18:56:02 +01:00

23 lines
697 B
Ruby
Executable File

class BalloonsController< ApplicationController
def show
url = URI.parse("http://api.heylium.io/public/v1/balloons/#{params[:id]}")
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|http.request(req) }
if res.code == "200"
@balloon = JSON.parse(res.body, {:symbolize_names => true})
url = URI.parse("http://api.heylium.io/public/v1/balloons/#{params[:id]}/comments")
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|http.request(req)}
@comments = JSON.parse(res.body, {:symbolize_names => true})
else
balloon_not_found
end
end
end