2016-02-03 52 views
1

我的默認圖像與載波一起工作,但我無法獲得默認的縮略圖版本。 @profile.photo@profile.photo.thumb都返回相同default_profile.png。我如何得到這個工作如何提供帶有載波的默認圖像的縮略圖版本

此外,當我上傳的照片,@profile.photo.thumb確實返回上傳的照片的大小調整後的版本。

/資產/圖像

我有default_profile.pngthumb_default_profile.png,後者是的,當然,一個按比例縮小前者的版本。我也嘗試了大拇指文件重命名爲default_profile_thumb.png

profile_photo_uploader.rb的

相關部分:

def default_url 
    "default_profile.png" 
end 

version :thumb do 
    process :resize_to_fill => [60, 60] 
end 

回答

2
def default_url 
"default_profile.png" 
end 

version :thumb do 
    process :resize_to_fill => [60, 60] 
    def default_url 
    "thumb_default_profile.png" 
    end 
end 
0

更好的方式TODO:

def default_url(*args) 
    ActionController::Base.helpers.asset_path([version_name, "default_profile.png"].compact.join('_')) 
    end