From d4e5077001f1ce4eb3aa6fc7d71db6a8ce207200 Mon Sep 17 00:00:00 2001 From: pbuckley Date: Thu, 23 Dec 2010 10:20:56 -0500 Subject: [PATCH] adding a basic post example --- examples/basic.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/basic.rb b/examples/basic.rb index 2e4e95f..d813795 100644 --- a/examples/basic.rb +++ b/examples/basic.rb @@ -9,3 +9,24 @@ puts response.body, response.code, response.message, response.headers.inspect response.each do |item| puts item['user']['screen_name'] end + +# An example post to a minimal rails app in the development environment +# Note that "skip_before_filter :verify_authenticity_token" must be set in the +# "pears" controller for this example + +class Partay + include HTTParty + base_uri 'http://localhost:3000' +end + +options = { + :body => { + :pear => { # your resource + :foo => '123', # your columns/data + :bar => 'second', + :baz => 'last thing' + } + } +} + +pp Partay.post('/pears.xml', options)