highcharts-rails
highcharts-rails copied to clipboard
Running 'rake assets:precompile' in dev mode makes Rails include Highchart code twice (Uncaught Highcharts error #16)
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 :
- run
rake assets:clean
- add the line
//= require highcharts
to app/assets/javascripts/application.js - run
rake assets:precompile
-
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 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