0
如何在不更改DataBase中的記錄的情況下更改控制檯上傳的文件名?Rails Carrierwave更新上傳的文件名
例如:
Photo.first.image.file
=> #<CarrierWave::SanitizedFile:0x007fdeabefbd98 @file="/.../public/uploads/app/2/photo/3_venice.jpeg", @original_filename=nil, @content_type=nil>
Photo.first.image.file.exists?
=> false
Photo.first.image.file.file
=> "/.../public/uploads/app/2/photo/3_venice.jpeg"
我的最終目標是找到文件的一些相關的名稱,如(不包括第一個符號,模型ID - 3):venice.jpeg
,重命名爲所需名稱:3_venice.jpeg
可能嗎?