Updating attachment only wont work #19

phlppn opened this Issue Apr 26, 2010 · 4 comments


None yet

4 participants

phlppn commented Apr 26, 2010

When i try to modify a document in CouchDB, just by changing or adding an attachment, this change is not recognized and couch_potato does not send any changes to the database. Only if i modify an additional element, it uploads the changed document including the attachment.

CouchPotato::Config.database_name = 'test'
my_doc = CouchPotato.database.load_document("1")
data = "foo"
my_doc._attachments = {'html' => {'data' => data, 'content_type' => 'text/plain'}}
CouchPotato.database.save_document my_doc

For example my document (my_doc) has no attachment. After using this code, couch_potato wont upload anything, but if i add

my_doc.title = "Foo Title"

before i save the document, couch_potato recognizes a change in the document and uploads my attachment. Normaly it should do this without adding additional elements.
Same if there is an attachment already. Couch_potato needs another element to see that the document changed. "._attachment" only does not work.

update: if i use "is_dirty", it works without additional element


that's because the dirty tracking of couch potato doesn't track attachments. a workaround would be to call my_doc.is_dirty and then save. otherwise i'm happy to accept patches.

aL3xa commented Jul 12, 2012

Pls @langalex make this the default behaviour!


can you make a pull request for this?

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