Rails 3.1资产管道 - 关闭Heroku上的图像资产指纹? [英] Rails 3.1 Asset Pipeline - turn off image asset fingerprinting on Heroku?

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

问题描述

因为我在应用程序中使用的jQuery插件直接引用了图像,所以我试图关闭资产指纹。因此,我将 config.assets.digest = false 在我的production.rb中,但现在没有任何图像引用可以工作。 /assets/foo.png 只是返回一个空白的响应。



我真的不想改变jQuery插件的代码和添加erb图像助手,但我不知道还有什么其他的办法。坦率地说,图像的资产指纹识别似乎比它的价值更麻烦。



有人有任何见解吗?
$ b $如果你使用的是像ckeditor这样的大插件,那么你唯一真正的选择就是移动它。该插件进入公共目录。



对于较小的插件,您可以将其图像移动到正确的资产路径中。例如,如果插件在插件文件夹下引用 images / icon.jpg ,则需要将其移动到 app / assets / images / plugin_name /icon.png ,然后在插件中引用<%= asset_tag('plugin_name / icon.png')%>



管道是值得的。在生产中不使用摘要几乎否定了使用它的要点,即设置远远的标题,以便将资源缓存到某处。



如果您是设置去除摘要,然后你必须预先编译资产(以便Sprockets不会为它们提供远期标题),并确保服务器上没有设置标题。


Because a jQuery plugin I use in my application has direct references to images, I'm trying to turn off asset fingerprinting.

So I set config.assets.digest = false in my production.rb, but now none of my image references work at all. /assets/foo.png just returns a blank response.

I really don't want to alter the jQuery plugin's code and add erb image helpers, but I'm not sure what else to do. And frankly, the asset fingerprinting for images seems to be much more trouble than it's worth.

Does anybody have any insight?

Thanks!

解决方案

If you are using a large plugin, like ckeditor, then your only real option is to move that plugin into the public directory.

For smaller plugins you can move their images into the correct asset path. For example if your plugin references images/icon.jpg under the plugin folder this would need to be moved to something like app/assets/images/plugin_name/icon.png and then referenced in the plugin with <%= asset_tag('plugin_name/icon.png') %>.

The pipeline IS worth it. Not using digests in production pretty much negates the point of using it at all, which is to set far-future headers so that the asset gets cached somewhere.

If you are set on removing digests then you must precompile the assets (so that Sprockets does not serve them with far-future headers), and make sure no headers are set on the server.

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

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