Skip to content

Instantly share code, notes, and snippets.

@ferrous26
Created May 19, 2011 05:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrous26/980256 to your computer and use it in GitHub Desktop.
Save ferrous26/980256 to your computer and use it in GitHub Desktop.
Problem in MacRuby somewhere...but where?
require 'json'
require 'rubygems'
require 'restclient'
# setup db
DB = 'http://127.0.0.1:5984/test'
RestClient.delete DB rescue nil
RestClient.put DB, {}.to_json
# setup a document
doc = { '_id' => 'test' }
resp = JSON.parse RestClient.put("#{DB}/test", doc.to_json)
# prepare the document
image = IO.read '/Applications/Mail.app/Contents/Resources/AccountPreferences.tiff'
# put it in the db
RestClient.put(
"#{DB}/test/#{resp['_id']}/test.tiff?rev=#{resp['rev']}",
image,
content_type:'image/tiff'
)
@ferrous26
Copy link
Author

This works with CRuby, but not on MacRuby. I haven't figured out why yet, but I think it losing some informating somewhere in net/http when it makes the PUT request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment