[英]Ruby on Rails 6 how to reference images from asset pipeline for css
I am trying to create a rails 6 application. 我正在尝试创建Rails 6应用程序。 In rails 5 while sass was still applicable I would use image-url(xxx.png) to reference images within the asset pipeline. 在sass仍然适用的Rails 5中,我将使用image-url(xxx.png)引用资产管道中的图像。 However, in rails 6 this is no longer applicable with web pack. 但是,在导轨6中,这不再适用于Web Pack。 I cannot seem to load up the image. 我似乎无法加载图像。
I have tried using different tags like asset-url, adjusting the url for a direct path but with no luck. 我尝试使用不同的标签(例如asset-url),调整URL的直接路径,但没有运气。
.banner { background-image: url(asset_path('home/head-banner.png')); .banner {background-image:url(asset_path('home / head-banner.png'));; ... } ...}
.banner { background-image: image-url('home/head-banner.png'); .banner {background-image:image-url('home / head-banner.png'); ... } ...}
The expected result is the fully hashed url for the image. 预期结果是图像的完全哈希URL。
A quick fix solution that should work: 一种快速修复的解决方案应该起作用:
This should work without fault and will allow you to use the rails helper functions. 这应该可以正常工作,并允许您使用rails helper功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.