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; //$(\'
Here's a few different options on how to do it:
http://jing.io/t/pass-javascript-variables-to-rails-controller.html