I have model Company and company has mounted carrierwave uploader Logo.
class Company < ActiveRecord::Base
mount_uploader :logo, LogoUploader
I experienced the same and figured it out that an uploader class' filename
method should not set a new filename unless original_filename
presents. CarrierWave has a relevant wiki page about filename which doesn't directly address this issue, but is enough to get a clue.
For example,
This code changes the filename field every time the model is updated.
class SampleUploader < CarrierWave::Uploader::Base
def filename
"#{Time.now.strftime('%Y%m%d%H%M%S')}.jpg"
end
end
However this extra if statement prevents the former behaviour.
class SampleUploader < CarrierWave::Uploader::Base
def filename
"#{Time.now.strftime('%Y%m%d%H%M%S')}.jpg" if original_filename.present?
end
end