Skip to content

Instantly share code, notes, and snippets.

By default, Rails 3.2 loads everything in app/javascripts and everything in app/stylesheets on
every page, despite controller-specific file naming. If you want to load controller-specific
files only on views from their respective controllers, you need to change the manifests and the
layout. The basic idea is to NOT require the entire trees, but only specific subfolders, in the
manifests, and then load the controller-specific files separately in the layout.
Any file you DO want loaded on every page should be placed in app/assets/javascripts/general or
app/assets/stylesheets/general.
For this to work in production, you also need to ensure that the individual files are precompiled by modifying your production.rb file, listing all of the controller-specific files.