问题描述
我有一个脚本 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-assetswhich adds non-digest versions of assets for rake assets:precompile
.
这篇关于静态路由到咖啡资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!