Precompile Assets

In development mode, the Rails asset pipeline “live compiles” all CSS
and JavaScript files and makes them available for use. Compiling assets
adds processing overhead. In production, a web application would be
slowed unneccesarily if assets were compiled for every web request.
Consequently, we must precompile assets before we deploy our application
to production.

When you precompile assets for production, the Rails asset pipeline will
automatically produce concatenated and minified application.js and
application.css files from files listed in the manifest files
app/assets/javascripts/application.js and
app/assets/stylesheets/application.css.scss. You must commit the
compiled files to your git repository before deploying.

Here’s how to precompile assets and commit to the Git repo:

$ RAILS_ENV=production rake assets:precompile