markevans/dragonfly — pull request #242 by mbrictson (2012-12-22 01:44:06+00:00)
Title: Handle case when existing uid is empty string (treat it like nil)

This pull request fixes a bug in a (rare) edge case where empty strings are somehow present for existing uid values. A test is included.

Longer explanation:

I had added an appropriate `_uid` column to my model according to the docs, and began creating records in my app using scaffold. At this point I had not yet fully integrated dragonfly with `image_accessor`. As a result, there were records in my database with empty strings for the `_uid` column (due to the scaffold form submissions).

When I then finished setting up dragonfly and tried to upload an image to one of these existing records, things went wrong: `Attachment#destroy_content` would get called with the empty string (the old uid), which the underlying datastore considers an invalid value.