I just started delving into javascript to make project more responsive and I am working through a backbone.js example.
I\'ve replicated http://www.jamesyu.org/2011/01/27
My answer is similar to @ream88's, but Rails 3.1+ Asset Pipeline feature takes care of minification, bundling and so on, so I prefer to have the un-minified versions available for debugging, etc.
So download the commented/full version of backbone.js and underscore.js and save them in app/assets/javascripts
(you could also save them in vendor/assets/javascripts
).
The difference is that you should update the manifest file (app/assets/javascripts/application.js
) to add the require directives, like so
//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require_tree .
Because backbone depends on underscore, this will cause them to get loaded in the right order, thus avoiding the error.