I have this Javascript view in my Rails 3 project:
app/views/expenses/new_daily.js.erb
var i = parseInt($(\'#daily\').attr(\'data-num\')) + 1; //$(\'
Check out the gon gem. https://github.com/gazay/gon
It gives you a simple object you can pass variables to that will be available to your scripts via window.gon
window.gon
Also referenced here http://railscasts.com/episodes/324-passing-data-to-javascript