简体   繁体   English

Image_tag和Turbolink

[英]Image_tag and turbolink

I started my journey with Rails and Ruby a couple of days ago and so far it is going well and I'm loving it! 几天前,我开始了Rails和Ruby的旅程,到目前为止一切进展顺利,我很喜欢!

Though, I do have a minor concern that I cannot find a solution to. 虽然,我确实有个小小的担忧,但我找不到解决方案。 I've had a minor sneak peek on turbolink and how that is embedded with Rails. 我对turbolink以及如何将其嵌入Rails进行了一些小小的偷窥。 But, my question (problem?) is that whenever I import/include an image (which is located in app/assets/image ) with Rails image_tag(...) , that image is reloaded whenever I redirect to another page. 但是,我的问题(问题?)是,每当我使用Rails image_tag(...)导入/包括一个图像(位于app / assets / image中 )时,只要重定向到另一个页面,该图像就会重新加载。 But if I use <img src="..." whereas the src is an extern link (image fetched from another page) it is not being re-fetched (meaning, it's cached when I redirect to another page). 但是,如果我使用<img src="..."而src是外部链接(从另一页面获取的图像),则不会被重新获取(意味着,当我重定向到另一页面时将其缓存)。

So my question is: is there a special way to apply turbolink to image_tag ? 所以我的问题是:是否有一种特殊的方法将turbolink应用于image_tag

Thanks. 谢谢。

This is because you are running in development mode. 这是因为您正在开发模式下运行。 Rails uses an "Asset Pipeline. When in development environment it reloads the assets. Rails使用“资产管道”。在开发环境中,它会重新加载资产。

When you come to production, you will see the difference. 当您投入生产时,您会看到不同之处。

You can read more about it here: http://guides.rubyonrails.org/asset_pipeline.html 您可以在此处了解更多信息: http : //guides.rubyonrails.org/asset_pipeline.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM