我正在使用回形针将图像保存在 s3 中。以下是我的模型中的代码
has_attached_file :pic, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml",
:url => '/image/file/:basename.:extension',
:path => '/image/file/:basename.:extension',
:bucket => 'Test'
问题是每当我保存具有相同名称的图像时,如果已经存在具有该名称的图像,图像就会被替换。我想更改文件的名称。我在创建新项目期间保存图像。那么我可以使用项目的 id 作为文件的名称,以便图像是唯一的吗?如果是,那我该怎么做?请帮我。