Nithin Bekal About

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
end

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

Hi, I’m Nithin! This is my blog about programming. Ruby is my programming language of choice and the topic of most of my articles here, but I occasionally also write about Elixir, and sometimes about the books I read. You can use the atom feed if you wish to subscribe to this blog or follow me on Mastodon.