In rails you can do this:
<% name = @user.name %>
<script>
var name = <%= name%>;
alert(name);
//prints the name of the user
</script>
You can do this in reverse, like this
<% name = @user.name %>
<script>
var name = "John";
<% name %> = name;
</script>
<% @user.name = name %>
<%= name %>
<!-- prints the name of the user, in this case "John" -->
Obviously this doesn't work, but for the purpose of an example
The point is, can you pass the value of a javascript variable to a ruby variable in rails