From f1f4091bce7f5e3b8e387fff7b777934ca80ac33 Mon Sep 17 00:00:00 2001 From: Matt Olson Date: Thu, 8 Nov 2012 10:57:41 -0800 Subject: [PATCH 1/2] Revert 0df712cd5baefd7ef8fe0d351dbb0dbe216a0d50 --- lib/carrierwave/mount.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/carrierwave/mount.rb b/lib/carrierwave/mount.rb index 88db5a299..b68bb06d4 100644 --- a/lib/carrierwave/mount.rb +++ b/lib/carrierwave/mount.rb @@ -296,11 +296,11 @@ def initialize(record, column, options={}) end def write_identifier - return if record.frozen? || uploader.identifier.blank? - - value = remove? ? '' : uploader.identifier - - record.write_uploader(serialization_column, value) + if remove? + record.write_uploader(serialization_column, '') + elsif not uploader.identifier.blank? + record.write_uploader(serialization_column, uploader.identifier) + end end def identifier From ab033ea6bf07371248c93c8a8985c2f07ae81480 Mon Sep 17 00:00:00 2001 From: Matt Olson Date: Thu, 8 Nov 2012 12:56:36 -0800 Subject: [PATCH 2/2] Fix regression in 0df712cd5baefd7e -- 0df712cd5baefd7ef8fe0d351dbb0dbe216a0d50 introduced a regression for removal of uploads. We need to handle the case were the image identifier is empty, but remove_image is set. --- lib/carrierwave/mount.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/carrierwave/mount.rb b/lib/carrierwave/mount.rb index 88db5a299..bea59955e 100644 --- a/lib/carrierwave/mount.rb +++ b/lib/carrierwave/mount.rb @@ -296,11 +296,13 @@ def initialize(record, column, options={}) end def write_identifier - return if record.frozen? || uploader.identifier.blank? + return if record.frozen? - value = remove? ? '' : uploader.identifier - - record.write_uploader(serialization_column, value) + if remove? + record.write_uploader(serialization_column, '') + elsif not uploader.identifier.blank? + record.write_uploader(serialization_column, uploader.identifier) + end end def identifier