2015-11-05 44 views
0

我在導軌中使用CarrierWave上傳圖像以查找食物記錄。我已經在食物模型中創建了一列「頭像」,模板視圖中的上傳表單運行良好。如何在rails應用程序中添加圖像顯示

我想爲show.html.haml中的圖像添加一個顯示部分,並顯示爲食物記錄上傳的圖像。我怎樣才能實現呢?

現在在show.html.haml我做的是:

= link_to image_tag('picture.jpg'), @food_item.avatar.current_path 

回答

0
= link_to @food_item.avatar.current_path do 
    = image_tag(@food_item.avatar_url) if @food_item.avatar? 
相關問題