title: Rails: do we have anything built-in to output a ruby array as arguments to a javascript function call?
body: <p>Here's what I want, in wishful code:</p>
  
  <h3>in my controller action:</h3>
  
  <pre><code>@javascript_function_args = [ "foo", "bar", 1, [2, 3], { :zort =&gt; 'narf', :nom =&gt; 'cake' }]
  </code></pre>
  
  <h3>in my erb view:</h3>
  
  <pre><code>&lt;script … &gt;
    performAwesome(&lt;%= @javascript_function_args.to_js_args %&gt;);
  &lt;/script&gt;
  </code></pre>
  
  <h3>or, even better:</h3>
  
  <pre><code>  &lt;%= call_javascript_function :performAwesome, *@javascript_function_args %&gt;
  </code></pre>
  
  <h3>my expected output:</h3>
  
  <pre><code>&lt;script … &gt;
    performAwesome("foo", "bar", 1, [2, 3], { zort : 'narf', nom : 'cake' });
  &lt;/script&gt;
  </code></pre>
  
  <p>I suppose I could just <code>#to_json</code> the array and strip the wrapping brackets, but I'm wondering if there's something more specific to handle it.</p>