在 Rails 中获取没有 HTML 的图像 URL [英] Getting the image URL without the HTML in Rails
本文介绍了在 Rails 中获取没有 HTML 的图像 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Rails 中,有没有办法获取图像的 URL(通过 assets_host)并只返回图像的 URL?我想在我的 Javascript 中使用 assets_host 数据,但我只需要将 URL 插入到 JS 中,而不是整个 image_tag.
In Rails is there a way to get the URL to the image (going through the assets_host) and just return the URL of the image? I want to use assets_host data in my Javascript, but I just need to insert the URL into the JS, not the whole image_tag.
先谢谢你!
推荐答案
image_path
将返回(你猜对了)图像的路径.它与 image_tag
中使用的方法相同.
这篇关于在 Rails 中获取没有 HTML 的图像 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文