title: How to pass Ruby variables to a JavaScript function in a Rails view?
body: <p>I'm wondering what the best practice is for passing variables to JavaScript functions in a rails view.  Right now I'm doing something like:</p>
  
  <pre><code>&lt;% content_for :javascript do %&gt; 
    &lt;script type="text/javascript"&gt;
      Event.observe(window, 'load', function(){          
          js_function(&lt;%= @ruby_array.to_json %&gt;, &lt;%= @ruby_var %&gt;); )}
    &lt;/script&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Is this the right way to go about it?</p>