[Ruby] Rails asset precompile error’ActionView::Template::Error (The asset application.css is not present in the asset pipeline.’

less than 1 minute read

Background

  • When I deployed the Rails application I created and accessed the page, the following error screen appeared and I could not access it.

  • So, when I checked log/production.rb, I got the following error

log/production.rb


ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.):

I’ve taken a lot of time to resolve this error, so I’m not sure how to do it right, but I’ll share the solution in my environment.

Environment

Rails 5.2.4 Ruby 2.6.4

solution

Edited config/environments/production.rb as follows

# Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
+ config.assets.compile = true

References

  • https://freebsd.sing.ne.jp/lang/ruby/13/07.html
  • [Asset Pipeline](https://railsguides.jp/asset_pipeline.html#%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%82%92%E3%83%97%E3%83%AA%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%AB%E3%81%99%E3%(82%8B)