Last minute fix for Rails 3.1 Stable

Beware of the config.assets.digest fingerprinting defaults!

As you all might be well aware, Rails 3.1 was released yesterday (August 31st 2011) … and for those of you whom have been developing using the Rails 3.1 beta and RC versions, you may have noticed a small gotcha which occurred in the Rails production configuration that may affect your asset filenames. If you notice that your asset file names are missing a fingerprint hash, md5 token, digest, hash timestamp (or whatever you want to call it) within their filenamelike application-xxxxxx.js then the reasoning behind this is because Rails 3.1 disables the config.assets.digest option by default for all environments.

Last Updated

This page was last updated on September 1st 2011 and was first published on September 1st 2011.

What to do?

The solution is simple, in your production.rb environment file, just set the following:

config.assets.digest = true

Turns out that this is documented in the Asset Pipeline Guide, however, since it was enabled by default in previous versions of the Rails 3.1 RC release, I figured that the problem was with my setup and not with Rails.

Why this is important?

Hopefully this helps. Instead of having to spend a couple of hours testing previous versions of Rails 3.1 stable, RC5 and so on, now you know better :) My story was that I was using a separate domain to host the precompiled assets folder so that Rails wouldn’t even get close to serving those asset files on my production server. Then I noticed that, despite the assets being successfully generated and fingerprinted during the rake assets:precompile operation, the javascript, stylesheet and asset helpers were not expanding their fingerprinted filename values. Thankfully, after hopping into the #rubyonrails IRC channel, this issue was quickly extinguished. Many thanks to the rubyonrails dev team.

One Response to “Last minute fix for Rails 3.1 Stable”

  1. Mickele:

    Thanks!
    And I love MooTools as well, nice material here, subscribed.
    :)

Add Your Comment