jakehow (owner)

Revisions

gist: 76525 Download_button fork
public
Public Clone URL: git://gist.github.com/76525.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
>> s = Statement.new
=> {"updated_at"=>nil, "couchrest-type"=>"Statement", "created_at"=>nil}
>> s.create_attachment(:name => 'test.txt', :content_type => 'text/plain', :file => File.open('test.txt'))
=> {"content-type"=>"text/plain", "data"=>"dGVzdAo="}
>> s.save
=> nil
>> s['_attachments']['test.txt']
=> {"content-type"=>"text/plain", "data"=>"ZEdWemRBbz0="}
>> s['_attachments']['test.txt']['content-type']
=> "text/plain"
>> s.id
=> "34f4cbdc4b304649366645fa692455ab"
>> x = Statement.get(s.id)
=> {"updated_at"=>Mon Mar 09 18:23:52 -0400 2009, "_rev"=>"961074468", "_id"=>"34f4cbdc4b304649366645fa692455ab", "couchrest-type"=>"Statement", "_attachments"=>{"test.txt"=>{"content_type"=>"application/octet-stream", "stub"=>true, "length"=>8}}, "created_at"=>Mon Mar 09 18:23:52 -0400 2009}
>> x['_attachments']['test.txt']
=> {"content_type"=>"application/octet-stream", "stub"=>true, "length"=>8}