lib/cloudinary/carrier_wave/storage.rb in cloudinary-1.0.49 vs lib/cloudinary/carrier_wave/storage.rb in cloudinary-1.0.50
- old
+ new
@@ -2,12 +2,18 @@
def store!(file)
return if !uploader.enable_processing
if uploader.is_main_uploader?
case file
- when Cloudinary::CarrierWave::PreloadedCloudinaryFile
- return store_cloudinary_version(file.version)
+ when Cloudinary::CarrierWave::PreloadedCloudinaryFile
+ if uploader.public_id && uploader.auto_rename_preloaded?
+ @stored_version = file.version
+ uploader.rename
+ else
+ store_cloudinary_version(file.version)
+ end
+ return
when Cloudinary::CarrierWave::CloudinaryFile
return nil # Nothing to do
when Cloudinary::CarrierWave::RemoteFile
data = file.uri.to_s
else
@@ -41,10 +47,10 @@
end
nil
end
def store_cloudinary_version(version)
- name = "v#{version}/#{identifier.split("/").last}"
+ name = "v#{version}/#{identifier.split("/", 2).last}"
model_class = uploader.model.class
column = uploader.model.send(:_mounter, uploader.mounted_as).send(:serialization_column)
if defined?(ActiveRecord::Base) && uploader.model.is_a?(ActiveRecord::Base)
primary_key = model_class.primary_key.to_sym
if Rails.version >= "3.0"