Rails 4.2: "Assets should not be requested directly without their digests"
Posted
by
Nowaker
on Stack Overflow
See other posts from Stack Overflow
or by Nowaker
Published on 2014-08-24T04:10:42Z
Indexed on
2014/08/24
4:20 UTC
Read the original article
Hit count: 233
ruby-on-rails
|ruby-on-rails-4
On Rails 4.2.0.beta1 I get an error:
Assets should not be requested directly without their digests: Use the helpers in ActionView::Helpers to request fonts/source-sans-pro.woff
The stylesheet:
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 400;
src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url(/assets/source-sans-pro.woff) format('woff');
}
The configuration is:
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.assets.version = '1.0'
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.assets.precompile += %w(.svg .eot .woff .ttf)
Sure I can disable digests and it works again, but I'm interested in using them. Therefore, how do I make use of digests when I need to request source-sans-pro.woff
?
Please note that I place the fonts in assets/fonts
directory, not the public/
directory. I don't see a difference between images and fonts, so I want to keep them under the same directory - app/assets
.
© Stack Overflow or respective owner