Created
June 16, 2011 15:56
-
-
Save schowdhury/1029563 to your computer and use it in GitHub Desktop.
talking REST with json payload... first curl and then activeresource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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