You could use something like this to write the variable to a JS global you could access from your script.

On some applications I even does this with an `APP` global which had multiple values.  There is also a project, https://github.com/gazay/gon, that tries to make it simple to implement.

```ruby
javascript:
  window.GAME_ID = "#{session[:game_id]}
```