Skip to content

Instantly share code, notes, and snippets.

@schowdhury
Created June 16, 2011 15:56
Show Gist options
  • Save schowdhury/1029563 to your computer and use it in GitHub Desktop.
Save schowdhury/1029563 to your computer and use it in GitHub Desktop.
talking REST with json payload... first curl and then activeresource
#Please excuse the naming of things, this is a on the fly contrived example
curl -i -H "Content-Type: application/json" -H "Accept: application/json"
-X POST -d '{"a_request":{"thing_ids":[1,2,3,4]}}' http://localhost:3000/a_requests
produces....
Started POST "/a_requests" for 127.0.0.1 at 2011-06-16 11:53:21 -0400
Processing by ARequests#create as JSON
Parameters: {"a_request"=>{"thing_ids"=>[1, 2, 3, 4]}}
.....
and now the encapsulation with ActiveResource:
class ARequest < ActiveResource::Base
self.site = "http://localhost:3000"
end
ARequest.create :thing_ids => [1,2,3,4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment