highcharts-rails icon indicating copy to clipboard operation
highcharts-rails copied to clipboard

Running 'rake assets:precompile' in dev mode makes Rails include Highchart code twice (Uncaught Highcharts error #16)

Open bluebird-communication opened this issue 9 years ago • 1 comments

I had problem with the error Uncaught Highcharts error #16 saying that Hightcharts was loaded twice.

I did not understand as I followed recommended settings in Highcharts-rails ReadMe. My application is using Rails 3.2.21.

More explanation about my debug can be found here.

Finally, I found that there is a bug in rails when you do a rake assets:precompile that would lead to include twice the Javascript code from app/assets and public/assets.

This bug is referenced here since april 2013, but the rails community don't seem to be willing to correct it.

As workaround I just :

  1. run rake assets:clean
  2. add the line //= require highcharts to app/assets/javascripts/application.js
  3. run rake assets:precompile
  4. deleted the line //= require highcharts from app/assets/javascripts/application.js

So Highchart library is precompiled in assets pipeline from the public/assets.

Its a bit weird, but it works... in development...

I still have to test it in production to confirm that it continues to work.

Maybe it would be a good idea to warn in the Highcharts-rails ReadMe file that including Highcharts in the app/assets/javascript/application.js file could potentialy lead to the error #16 ?

bluebird-communication avatar Apr 07 '15 11:04 bluebird-communication

@bluebird-communication is this still a problem? It's quite old, so I'm guessing (hoping) something probably changed, either in Rails or in Highcharts that makes this disappear

PerfectlyNormal avatar Nov 10 '17 22:11 PerfectlyNormal