Skip to content

Instantly share code, notes, and snippets.

@ilake
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilake/9092eccf5be0f67bd4dc to your computer and use it in GitHub Desktop.
Save ilake/9092eccf5be0f67bd4dc to your computer and use it in GitHub Desktop.
12 Tips for the Rails Asset Pipeline

http://www.reinteractive.net/posts/116-12-tips-for-the-rails-asset-pipeline

The asset pipeline is not quite your assets folder

  • Every file that is not a Javascript file or CSS file that is in the app/assets folder will be copied by Rails into the public/assets folder when you compile your assets.

Don't fall back in staging or production

  • config.assets.compile
  • If it is set to "true" (which it is by default in development) then Rails will try to find a Javascript or CSS file by first looking in the public/assets directory and if it can't find it, will hunt through your app/assets folder looking for the file. If it finds it in app/assets it will go ahead and compile on the fly and then serve this asset up.

It's all relative, mostly

  • require will look for any file that has the same name that is in in your assets load path. Don't know what your assets load path is? Well, fire up Rails console in the environment of your choice and run: Rails.application.config.assets.paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment