General javascript routines can be placed in the app/assets/javascripts folder. All js files will automatically be included in Rails views.
In order to implement incremental search, this zipped cinema app has the javascript code in the javascripts folder (see inc_search.js).
As of of Rails 3.1, javascript can be specified as CoffeeScript. Rails automatically translates CoffeeScript code to javascript when the file is included in a Rails view.
This zipped cinema app has the working CoffeeScript code in the javascripts folder (see movies.js.coffee).