Why is javascript not working on deployment in heroku?

After deploying the Rails application to Heroku, no javascript functions work.

The files appear to have been compiled (although it is not easy to see in the mini file).

What is the logical process of steps to understand why javascript is not working (it works great in the production process).

thanks

+6
source share
2 answers

Sometimes I have problems due to the asset pipeline and my misunderstanding. So, what am I doing to make sure everything is packed correctly, just added a simple warning when loading the page (put it on some random users that users cannot reach, etc.)

alert('some-unique-string') 

Send the code to the server. Then in chrome print the page and use the dev tools, go to the "scripts" tab. From there, you can find the string some-unique-string , since your string literal will not be reduced. If you do not see this, you know that your javascript is not included for some reason.

This will at least give you a starting point.

+3
source

This problem is related to the asset pipeline. You must compile the assets.

To solve this problem, Turn config.assets.compress to true in config / environment / production.rb,

ie

  config.assets.compress = true 

Then run RAILS_ENV=production bundle exec rake assets:precompile .

Repeat the code.

+6
source

Source: https://habr.com/ru/post/917603/


All Articles