0
votes

I have just upgraded to Rails 3.1, and I am having an issue with loading my Javascripts with the new asset pipeline.

I have copied the js files (both the files themselves and their .min variants) into my /app/assets/javascripts directory, and my application.js manifest is as follows:

//= require jquery
//= require jquery_ujs
//= require jquery-easytabs
//= require jquery-hashchange.min
//= require_tree .

But this does not appear to be working; Easytabs is not being loaded correctly. Strangely, when I look in the console at the application.js file that is compiled, I can see the Easytabs code, but it is not working.

I have found that if i paste the code directly into the application.js file, it works as expected, so I know that the script is working. This is not, however, the intended use of the application.js file.

I would appreciate any guidance on where to go next in order to ensure the correct loading of the js files.

Thanks!

2
I've answered a similar question here: stackoverflow.com/questions/6149961/…justingordon

2 Answers

0
votes

Try moving all your plugins (like easytabs) into the vendor directory.

vendor/assets/javascripts/

Then change your application.js file to this:

//= require jquery
//= require jquery_ujs
//= require_tree ../../../vendor/assets/javascripts
//= require_tree .

You should (if you aks me) only place code that you have written for a specific controller in your app/assets/javascripts directory, everything else, like plugins should go in the vendors dir.

0
votes

I managed to get to the bottom of this - it seems that the require order is alphabetical, so jquery_easytabs was getting compiled before jquery_ujs. I fixed this by renaming to jquery_zeasytabs - not the cleanest, but it does work.