Nithin Bekal Posts About Notes

Enable Asset Compression After Upgrading to Rails 4

28 Nov 2014

Recently, I upgraded an app from Rails 3.2 to 4.0. Things went smoothly, but I recently noticed that the JavaScript response was twice the size I expected it to be. Taking a closer look showed that Rails was no longer minifying the JS assets.

It turns out that the config.assets.compress = true directive no longer works in Rails 4. Instead, you need to specify the compressor in config/environment/production.rb like this:

MyApp::Application do
  config.assets.js_compressor = :uglifier

It is strange that this was changed without any deprecation messages, but luckily it didn’t cause much damage.

Nithin Bekal
Hi, I’m Nithin Bekal. I work at Shopify in Ottawa, Canada. Previously, co-founder of and WowMakers. Ruby is my preferred programming language, and the topic of most of my articles here, but I'm also a big fan of Elixir. Tweet to me at @nithinbekal.