资产的静态网址 [英] Static url to asset
问题描述
我有一个用coffeescript
编写的脚本my_pub_script.js.coffee
,我想将其公开,以便任何人都可以在example.com/scripts/my_pub_script.js
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
我可以将任何文件放在/public
中,但这是coffee
,我必须将其通过资产管道传递,以正确地将其编译为js
.
但是,如果我编译脚本,它将有一个带有指纹后缀的名称,例如my_pub_script-e55bd5e3eb82fa4e8034af2883dc37e8.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?
推荐答案
在rails '>= 3.1.1, < 4.0.0'
中,由于rake assets:precompile
的存在,每个资产都有摘要版本和非摘要版本.
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
.
在rails '>= 4.0.0'
中,根据此,我们只有摘要版本,没有任何摘要获得非消化性资产的可能性.
In rails '>= 4.0.0'
according to this we have only digest versions without any possibility to get non-digest assets.
现在,我们有几种解决方案.我更喜欢使用 non-stupid-digest-assets
会为rake assets:precompile
添加非摘要版本的资产.
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屋!