2012-12-17 40 views
7

回形針上傳圖片的原始路徑是什麼?如何在回形針中使用原始圖片網址

has_attached_file :attachment, 
    :url =>   ":rails_root/public/photos/images/:id/:style/:basename.:extension", 
    :default =>  ":rails_root/public/images/no-image-available.png", 
    :styles =>   style_options, 
    :default_style => :gallery 

和style_options是

style_options = { :thumbnail => {:geometry => '100x100'}, 
        :profile_gallery => {:geometry => '184x247'} 
        } 

在我的公共文件夾中創建文件夾3,而一個圖片上傳1.縮略圖,2 profile_gallary 3.原。

在我看來,我的文件叫

<%= photo.thumbnail_url %> 

我的問題是我想使用上傳圖片的原始路徑。我不想爲任何特定的網址使用thumnail。我如何使用原始路徑。

感謝提前

回答

8
<%= photo.attachment.url(:original) %> 

這將使你的路徑到原始文件,您還可以根據需要得到其他款式:

<%= photo.attachment.url(:thumbnail) %> 
<%= photo.attachment.url(:profile_gallery) %>