Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. url = URI.parse("http://www.student-info.net/sis-mapa/prehrana/sis-mapa/slika/slika_#{restaurant.online_id}.jpg")
  2.       req = Net::HTTP::Get.new(url.path)
  3.       res = Net::HTTP.start(url.host, url.port) do |http|
  4.         http.request(req)
  5.       end
  6.  
  7.       if res == Net::HTTPSuccess
  8.         File.open(RAILS_ROOT + "/public/images/restaurants/restaurant_#{restaurant.id}.jpg", "wb+") do |f|
  9.           f << res.body
  10.         end
  11.       end