I want to use the normal asset name, e.g. app.js
when calling the asset_path
helper in my views. In production, it uses the cache-busting name, e.g. app-f73cf13e6f100eda6681381e7d3ae9eb.js
.
Is there a way to get the normal name using asset_path
?
Redesigning the Asset Delivery: Key Ideas File fingerprinting is a versioning technique that binds the name of a file to its actual content, usually by adding the file hash to the name (e.g. logo-idealo-kr3u2vv3k0r.
We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.
The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output. These paths must be specified relative to the manifest file.
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
Figured it out, pretty simple actually. Just have to add digest: false
to asset_path like so:
asset_path('app.js', digest: false)
By default assets.digest is enable in production environment and is recommended for several reasons. However, if you really want to disable it write this in your production.rb
config.assets.digest = false
For more info refer http://guides.rubyonrails.org/asset_pipeline.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With