RailsCasts Pro episodes are now free!

Learn more or hide this

Passing Data to JavaScript

#324 Passing Data to JavaScript

Feb 13, 2012 | 6 minutes | Views, Plugins
There are a variety of ways to pass variables from a Rails application to JavaScript. Here I show three techniques: a script tag, a data attribute, and the Gon gem.
  • Download:
  • source codeProject Files in Zip (87.5 KB)
  • mp4Full Size H.264 Video (14.6 MB)
  • m4vSmaller H.264 Video (7.43 MB)
  • webmFull Size VP8 Video (9.2 MB)
  • ogvFull Size Theora Video (16.3 MB)