0

我目前使用carrierwave,我想知道如果他以下他可能。如果是这样!!在此先感谢CarrierWave不覆盖以前的页面

我有一个用户,想上传头像,然后下面的文件夹将被创建

public/image/avatar/customer.id/image01/small 
public/image/avatar/customer.id/image01/normal 
public/image/avatar/customer.id/image01/big 

public/image/avatar/customer.id/image02/small 
public/image/avatar/customer.id/image02/normal 
public/image/avatar/customer.id/image02/big 

基本上,我不想在此改变之前的图像有我想留住他们,但为最新的图片创建一个文件夹,让它在那里。还希望客户ID有一个路径。

谢谢。 PS:如果可能的话,请提供一个教程或somesort,如果不可能回形针允许它吗?谢谢,我似乎无法找到任何有关它。

回答

0

上传/ image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base 

# Include RMagick or MiniMagick support: 
include CarrierWave::RMagick 
# include CarrierWave::MiniMagick 

# Choose what kind of storage to use for this uploader: 
storage :file 

# Override the directory where uploaded files will be stored. 
# This is a sensible default for uploaders that are meant to be mounted: 
    def store_dir 
    "public/image/avatar/#{current_user.id}" 
    end 

    version :small do 

    end 

    version :normal do 

    end 

    version :big do 

    end 

end 

您的图片上传看起来应该这样。