If you are using Rails 4, most likely you are using Uglifier (UglifyJS) for JS compression for the assets pipeline.

Uglifier is awesome, but it happens to break the JS sometimes when using variable mangling. If you mix it with some CoffeeScript > AngularJS code there’s a high chance that something will go wrong.

You have two options:

  1. Write minification-safe AngularJS code.
  2. Edit your environment.rb file and turn off the mangling
    config.assets.js_compressor = Uglifier.new(:mangle => false) .
    Your JS files will grow a bit but the assets:precompile task will run crazy fast (really noticeable when you have A LOT of JS – can go down from 10 minutes to 15 seconds).

It’s up to you to decide if you go with 1. or with 2.