2

I have my application working fine locally in my development environment, however when I push to Heroku OR do RAILS_ENV=production rails s some of my JavaScript assets are not working. For example, I am using the cocoon gem and a datetimepicker that I found online (and placed into vendor/assets/javascripts). I have run RAILS_ENV=production rails assets:precompile and all of the assets that are not working I see in public/assets. Additionally, when I view the source on my pages and open up the application.js file, I can tell that the 3rd party JavaScript files are indeed compiled into the application.js because I have searched for some specific string literals and see them. Yet cocoon is not working and in my browser console I see TypeError: $(...).datetimepicker is not a function.

I am stumped since these are working in my development environment and all of the assets appear to be compiled into the application.js file. Any ideas on how to resolve this or even any direction on troubleshooting the issue further?

Edit:

So I stumbled upon this SO post: Disable Asset Minification in Rails Production, where the OP posted

In order to debug javascript in my heroku production environment, I need to disable asset compression (or at least compression of javascript).

And one of the comments recommended commenting out this line in production.rb: config.assets.js_compressor = :uglifier and add in config.assets.debug = true. Well I did this and BAM everything is working. Why is this? How can uglifier be breaking my code?

Community
  • 1
  • 1
Trinculo
  • 1,950
  • 1
  • 17
  • 22

0 Answers0