从rc6升级到Rails 3.1.0,资产预编译失败

aya*_*aya 14 ruby-on-rails

从Rails 3.1.0.rc6升级到Rails 3.1.0之后,运行这样的assets:precompile任务时出现了一些错误消息:

$ RAILS_ENV=production RAILS_GROUPS=assets rake assets:clean tmp:clear assets:precompile
rake aborted!
ie-spacer.gif isn't precompiled
  (in app/assets/stylesheets/jquery.gritter.css.scss)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)

我想补充config.assets.precompile << 'ie-spacer.gif'config/application.rb,但它仍然失败.

该行jquery.gritter.css.scss是:

background: asset_url('ie-spacer.gif', image);
Run Code Online (Sandbox Code Playgroud)

我试过了:

background: asset_path('ie-spacer.gif', image);
background: image_url('ie-spacer.gif');
background: image_path('ie-spacer.gif');
Run Code Online (Sandbox Code Playgroud)

一切都失败了ie-spacer.gif isn't precompiled.

小智 27

你必须做

config.assets.compile = true
Run Code Online (Sandbox Code Playgroud)

资产期间:预编译任务.

似乎是rails 3.1中的一个错误.

  • 这是Rails 3.1中的一个错误.您还可以升级到rails 3-1-stable分支,其中包括此修复程序:https://github.com/rails/rails/pull/2768/files (2认同)