Daniel Irvine on building software
Understanding the Rails asset pipeline
21 July 2014
This post helped me out today when getting to grips with the Rails asset pipeline.
The primary documentation on this subject is The Asset Pipeline. It’s good, except...
Various parts of asset pipeline are turned off by default in development mode. Namely, fingerprinting and minification do not happen. This was not obvious to me, although in hindsight it’s a fairly obvious decision: both fingerprinting and minification would be a hinderance to debugging.
In other words, the following line in your ERB template does different things depending on whether or not we’re running in development or production.
It will output something like this in production:
But in development, you’ll get something like this:
This might seem pretty simple but I was left scratching my head during my initial development. I was wondering why the famed asset pipeline wasn’t working, when actually the problem was just that I wasn’t running in production.