LoginSignup
29
30

More than 5 years have passed since last update.

Rails 3.2のproduction環境でisn't precompiledと出る場合の対処

Posted at

Rails 3.2でproduction環境で実行した際、下記のようなエラーが発生。

ActionView::Template::Error (application.css isn't precompiled):

アセットパイプラインという機能でapp/assets配下がコンパイルされていないとダメとのこと。

bundle exec rake assets:precompile RAILS_ENV=production

上記を実行して再度、試したところ次はCSSに対しActionController::RoutingErrorが発生。
調べると静的なファイルも含めてコンパイルする必要があるとのことで下記を追加。

config/environments/production.rb
config.serve_static_assets = true

無事に動作した。

他にも解決方法があり、下記のように設定するとコンパイル済みのアセットがなかったらコンパイルするようになる。

config/environments/production.rb
config.assets.compile = true

ちなみにコンパイル済みのアセットをクリアする方法は下記の通り。

bundle exec rake assets:clean RAILS_ENV=production
29
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
30