Commit fc7be8e

mo khan <mo@mokhan.ca>
2013-03-31 01:13:53
posting a new location to a server that does not exist
1 parent 127446e
Changed files (2)
app/controllers/location_controller.rb
@@ -22,6 +22,8 @@ class LocationController < UIViewController
       @add.enabled = false
       @text_field.enabled = false
       p @text_field.text
+      location = Location.new(@text_field, 1, 1)
+      location.save
     end
 
     access_twitter
app/models/location.rb
@@ -0,0 +1,19 @@
+class Location
+  attr_accessor :name, :latitude, :longitude
+
+  def initialize(name, latitude, longitude)
+    @name = name
+    @latitude = latitude
+    @longitude = longitude
+  end
+
+  def save
+    begin
+      BW::HTTP.post("http://localhost:3000/api/vi/restaurants", payload: {name: @name, latitude: @latitude, longitude: @longitude} ) do |response|
+        p response
+      end
+    rescue Exception => e
+      p e
+    end
+  end
+end