We recently upgraded one of our internal Rails projects to 3.1 and included the asset pipeline as part of the upgrade. Everything worked peachy in development, but when we'd compile and compress our JS assets, our JQPlot charting library would not work. It kept throwing errors like:
TypeError: Result of expression '$.jqplot' [undefined] is not a function TypeError: Result of expression 'getRootNode()' [undefined] is not an object
After digging around, it turns out that the problem was with how JQPlot was loading itself.
The solution was to ditch the included loader JS file, and create an equivalent file that works with Rails' asset pipeline. This involved making a file, app/assets/jqplot.js:
All the files in this loader file are from the jquery.jqplot.js file itself.
Our app/assets/application.js file then looks like this:
Once we had properly defined the files needed for our charting library, the compressed assets worked perfectly.