开发者

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

开发者 https://www.devze.com 2023-04-10 21:41 出处:网络
I am getting the following error: Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#edit

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 Ov开发者_运维百科erlay
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?


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.


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

In production.rb

  • config.assets.compile = true
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号