新しい Rails 3.1 アプリを作成しました。Twitter ブートストラップ CSS ファイルを app/assets/stylesheets/bootstrap.min.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
その後、元のコマンドも機能します(開発環境を指定せずに)。
では、どうすればエラーを追跡できますか? 今のところ、圧縮をオフにするだけで生活できますが、明らかに何かがおかしいです。レイルズですか?スプロケット? ルビーレーサー?醜い?