Rails 3.1 和图像资产 [英] Rails 3.1 and Image Assets

查看:41
本文介绍了Rails 3.1 和图像资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的管理主题的所有图像放在名为 admin 的文件夹内的资产文件夹中.然后我像往常一样链接到它.

I have put all my images for my admin theme in the assets folder within a folder called admin. Then I link to it like normal ie.

# Ruby    
image_tag "admin/file.jpg" .....
#CSS
.logo{ background:url('/assets/images/admin/logo.png');

仅供参考.只是为了测试,我还没有使用 asset_path 标签,因为我还没有编译我的资产.

FYI. Just for testing I am not using the asset_path tag just yet as I have not compiled my assets.

到目前为止一切都很好,直到我决定更新图像.我更换了一些颜色,但在重新加载时没有显示新样式的图像.如果我直接在浏览器中查看图像,它仍然显示旧图像.更进一步,我销毁了管理图像文件夹.但它没有破坏任何图像仍在显示.是的,我已经清除了缓存并尝试了多个浏览器.

Ok all good so far until I decided to update an image. I replaced some colors but on reload the new styled image is not showing. If I view the image directly in the browser its still showing the old image. Going one step further I destroyed the admin images folder. But it has broken nothing all the images are still being displayed. And yes I have cleared my cache and have tried on multiple browsers.

是否正在进行某种图像缓存?这只是使用 pow 服务页面的本地开发.

Is there some sort of image caching going on? This is just local development using pow to serve the pages.

即使销毁整个图像文件夹,图像仍在提供.

Even destroying the whole images folder the images are still being served.

我错过了什么吗?

推荐答案

在 3.1 中,您只需去掉路径的图像"部分.因此,位于 /assets/images/example.png 中的图像实际上可以在此 url 的 get 请求中访问 - /assets/example.png

In 3.1 you just get rid of the 'images' part of the path. So an image that lives in /assets/images/example.png will actually be accessible in a get request at this url - /assets/example.png

因为 assets/images 文件夹是与新的 3.1 应用程序一起生成的,所以这可能是他们希望您遵循的约定.我认为 image_tag 会在那里寻找它,但我还没有测试过.

Because the assets/images folder gets generated along with a new 3.1 app, this is the convention that they probably want you to follow. I think that's where image_tag will look for it, but I haven't tested that yet.

此外,在 RailsConf 主题演讲中,我记得 D2h 说 public 文件夹 中不应再包含太多内容,主要是错误页面和图标.

Also, during the RailsConf keynote, I remember D2h saying the the public folder should not have much in it anymore, mostly just error pages and a favicon.

这篇关于Rails 3.1 和图像资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆