静态路由到咖啡资产 [英] Static route to coffee asset

查看:175
本文介绍了静态路由到咖啡资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本 my_pub_script.js.coffee coffeescript 写的,我想让它公开所以任何人可以下载 example.com/scripts/my_pub_script.js



我可以将任何文件放在 / public 但是这是咖啡,我不得不通过它通过资产管道正确编译为 js

但是如果我编译我的脚本,它会有一个名称带有指纹后缀如 my_pub_script-e55bd5e3eb82fa4e8034af2883dc37e8.js strong>我不知道当前链接。



确实我有很多其他文件,我想通过资产管道正常。

解决方案

如何创建一个静态路由到一些coffeescript资产?在 rails'> = 3.1.1, 4.0.0' rake assets:precompile 结果中的每个资产的摘要版本和非摘要版本。



rails'> = 4.0.0'根据我们只有摘要版本没有任何可能性获取非摘要资产。



现在我们有几个解决方案。我更喜欢使用宝石非愚蠢的摘要资产
它为 rake assets:precompile 添加非摘要版本的资产。


I have a script my_pub_script.js.coffee written with coffeescript and I want to make it public so anybody can download it on example.com/scripts/my_pub_script.js

I can put any files in /public but this is coffee and I had to pass it through asset pipeline to properly compile it to js.
But if I compile my script it will have a name with fingerprint suffix like my_pub_script-e55bd5e3eb82fa4e8034af2883dc37e8.js so I don't know the current link to it.

Sure I have many other files that I want to pass through assets pipeline normally.

How I can make a static route to some coffeescript asset?

解决方案

In rails '>= 3.1.1, < 4.0.0' there was both digest and non-digest versions of every assets in result of rake assets:precompile.

In rails '>= 4.0.0' according to this we have only digest versions without any possibility to get non-digest assets.

Now we have several solutions. I prefer to use the gem non-stupid-digest-assets which adds non-digest versions of assets for rake assets:precompile.

这篇关于静态路由到咖啡资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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