RailsCasts Episode #324: Passing Data to JavaScript http://railscasts.com/episodes/324-passing-data-to-javascript Requires Ruby 1.9.2 or higher.