Rails 3.1不预编译CSS没有引用的图像?

And*_*rew 7 ruby-on-rails ruby-on-rails-3.1 asset-pipeline

我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

此图像文件位于app/assets/images/taxonomy/focus-building.jpg.我已经运行了rake assets:precompile RAILS_ENV=production,但据我所知,图像没有被复制到public/assets目录中.

奇怪的是,SCSS中引用的所有资产都image-url()可以正常使用.为什么这个图像报告在被引用时没有被预编译image_tag

cha*_* ly 0

我对 image_tag 也有同样的问题。我通过使用实时编译解决了这个问题。

生产中.rb

  • config.assets.compile = true