Search code examples
ruby-on-railscoffeescriptruby-on-rails-4asset-pipelineassets

Static url to asset


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?


Solution

  • 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.