簡體   English   中英

如何從Ruby File類編輯image_tag URL

[英]How to edit an image_tag url from Ruby File class

我有一個image_tag我正試圖從中刪除一些。

<%= link_to (image_tag (File.absolute_path(image))), image[/\/.*/]%>

它返回:

http://x.x.x.x/OPT/ROR/DIST_PORTAL/PUBLIC/FILES/...

我需要從image_tag網址中刪除“ / OPT / ROR / DIST_PORTAL / PUBLIC”,因此它具有以下內容:

http://x.x.x.x/FILES/...

你怎么做到這一點?

謝謝

<% image_path = ["/", File.dirname(image).split("/").last,"/", File.basename(image)].join('') %>
<%= link_to image_tag(image_path), image[/\/.*/]%>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM