iprog.com

Missing assets in Rails 4.0 (part 2)

In addition to the asset path changes covered in part 1, there are some changes in how processed asset files are exposed to web clients.

In this case, the problem shows up with asset files that are referenced by name without the md5 fingerprint. Previously, plain-named asset files were also exposed to the webserver. Now they don’t seem to be.

The most likely culprit here are files referenced from within a CSS file, such as:

1src: font-url('custom-webfont.eot');
2
3background: url('background.png');

In this case, you’ll need to use the asset_path helper like so:

1src: url('<%= asset_path('custom-webfont.eot') %>');
2
3background: url('<%= asset_path('background.png') %>');

You may need to rename your css file to enable ERB parsing, eg: design.css becomes design.css.erb.

Another possibility are hard-coded asset references in your view templates somewhere. Once again, change such references to use the asset_path helper.

tags: rails, rails4, assets