我知道image_tag ,返回资源的 html 标签。如果没有给出绝对路径,则资源安装在 assets
下。
这个assets根路径怎么弄?我想避免在我的应用程序中使用硬编码的 File.join('assets','other_resource')
。
最佳答案
你要找的东西,确切地说,不清楚...
但是,假设您想要图像资源的相对路径,您可以使用 image_path
:
image_path("other_resource.png") # => /assets/other_resource.png
如果你想要图像资源的绝对路径,你可以使用image_url
:
image_url("other_resource.png") # => http://example.com/assets/other_resource.png
关于ruby-on-rails - 如何获取 Assets 根路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25709227/