Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting 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 have run rake assets:precompile RAILS_ENV=production, but as far as I can tell the images are not being copied to the public/assets directory.

Strangely, all assets that are referred to in SCSS using image-url() work fine. Why does this image report not being precompiled when referred to with image_tag?

like image 402
Andrew Avatar asked Oct 04 '11 17:10

Andrew


1 Answers

If you have the assets.digest option enabled this will add a hash at the end of the name and so a static reference to that file will no longer work, change any statically-referenced assets so that they use the helper methods.

like image 185
Luca G. Soave Avatar answered Nov 02 '22 23:11

Luca G. Soave