2017-05-30 35 views
0

我的圖像位於/app/assets/images/myfolder/a.png。我想在api中返回圖片網址。那麼,如何在控制器中獲得這個路徑? 我已經嘗試過以下在控制器中查看圖像路徑

ActionController::Base.helpers.image_path('myfolder/a.png') 
ActionController::Base.helpers.asset_path('myfolder/a.png') 
view_context.image_path('myfolder/a.png') 

但沒有任何作品。

回答

1

試試這個

ActionController::Base.helpers.image_url('myfolder/a.png') 
+0

是否使預編譯的路徑? –

+0

yes..it does ... –

+0

好的,讓我試試。 –

相關問題