title: ruby array to javascript - Rails
body: <p>I am trying to pass a ruby array to a js view (<em>js.erb</em> format) but it doesn't work at all.</p>
  
  <p><code>var array = "&lt;%= @publishers_list %&gt;";</code></p>
  
  <p>The variable <em>array</em> is just set as a <em>string</em> with all the array's values in it.</p>
  
  <p>Is there a way to keep the array format ?</p>
  
  <h3>Edit</h3>
  
  <p>I just realized it was because  of my array format.</p>
  
  <p><code>[{:label =&gt; "name1", :value =&gt; value1}, {:label =&gt; "name2", :value =&gt; value2}]</code></p>
  
  <p>I tried to pass a simple array like:</p>
  
  <p><code>[1,2,3]</code></p>
  
  <p>and it worked fine.</p>
  
  <p>The question is now: how can I pass this kind of array ? I really need to keep these hashes in it because I want to put it as a source of a jQuery autocomplete.</p>