Rails 3.1 does not precompile images that are not referenced by CSS?

I get the following error:

Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#edit Showing .../app/views/photos/_form.html.haml where line #49 raised: taxonomy/focus-building.jpg isn't precompiled Extracted source (around line #49): 46: = focus.code 47: .tooltip 48: %span.name= focus.name 49: = image_tag("taxonomy/focus-#{focus.code.downcase.dehumanize}.jpg") 50: / Help Overlay 51: .help 52: %a.overlay{:href=>"#", :rel=>'#help-focus'} Learn more about focus 

This image file is located in app/assets/images/taxonomy/focus-building.jpg . I ran rake assets:precompile RAILS_ENV=production , but as far as I can tell, the images are not copied to the public/assets directory.

Oddly enough, all the assets mentioned in SCSS using image-url() work fine. Why won't this image be precompiled when mentioning image_tag ?

+7
source share
2 answers

If you have the asset.digest parameter enabled, this will add a hash at the end of the name, and therefore the static link to this file will no longer work, change any statically linked assets so that they use auxiliary methods.

+2
source

I had the same problem with image_tag. I solved the problem using live compilation.

In production.rb

  • config.assets.compile = true
0
source

All Articles