我创建了一个全新的 Rails 3.1 应用程序。我在 app/assets/stylesheets/bootstrap.min.css 中添加了 twitter 引导 CSS 文件。这是相关代码
app/assets/stylesheets/application.css(包括树,所以包括引导程序)
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
Gemfile(包括用于编译/压缩的 execjs 和 therubyracer)
group :development, :qa do
gem 'execjs'
gem 'therubyracer'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier', '>= 1.0.3'
end
然后我运行 rake 任务来预编译资产
rake assets:precompile
这失败并出现以下错误
Invalid CSS after ".inputs-list li+": expected number or function, was "li"
CSS 在引导文件中(“.inputs-list li+li”是选择器)。
但是,如果我运行
rake assets:precompile RAILS_ENV=development
现在它工作正常。事实证明,如果我将 config/environments/production.rb 更改为不压缩文件:
config.assets.compress = false
那么原始命令也可以工作(不指定开发环境)。
那么,我该如何追踪错误呢?我现在可以忍受只关闭压缩,但显然有问题。是导轨吗?链轮?红宝石赛车手?丑化剂?