From 84b8e1664ad263c700e670a585ee167a3e3e6ec4 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Wed, 12 Apr 2017 15:57:51 -0600 Subject: [PATCH] Don't store "_old_" if we're passed `nil` --- lib/carrierwave/mongoid.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/carrierwave/mongoid.rb b/lib/carrierwave/mongoid.rb index 53063a7..c90f09c 100644 --- a/lib/carrierwave/mongoid.rb +++ b/lib/carrierwave/mongoid.rb @@ -48,7 +48,7 @@ def #{column}=(new_file) @_previous_uploader_value_for_#{column} = previous_uploader_value # mongoid won't upload a new file if there was no file previously. - write_uploader(column, '_old_') if self.persisted? && read_uploader(column).nil? + write_uploader(column, '_old_') if self.persisted? && read_uploader(column).nil? && !new_file.nil? send(:"\#{column}_will_change!") super