Twitter GitHub Facebook Instagram dirv.me

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.

<%= javascript_include_tag application %>

It will output something like this in production:

<script src=/assets/application-2be52519875b1b82fc1405140f2957d3.js></script>

But in development, you’ll get something like this:

<script src=/assets/application.js></script>

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.

About the author

Daniel Irvine is a software craftsman at 8th Light, based in London. These days he prefers to code in Clojure and Ruby, despite having been a C++ and C# developer for the majority of his career.

For a longer bio please see danielirvine.com. To contact Daniel, send a tweet to @d_ir or use the comments section below.

Twitter GitHub Facebook Instagram dirv.me