title: Access ruby array in javascript
body: <p>I want to access a Ruby array in javascript. Please tell me the method to do that. My array is holding the result of a sql query. </p>
  
  <pre><code>  @contacts = Contact.order("contacts.position ASC")
  </code></pre>
  
  <p>I am trying to do this....</p>
  
  <pre><code>for(var i=0; i&lt; a; i++)
      {   
          var firstnameV = "&lt;%=Contact.order('contacts.position ASC')[i].first_name%&gt;";
          var lastnameV = "&lt;%=Contact.order('contacts.position ASC')[i].last_name%&gt;";
          var emailV = "&lt;%=Contact.order('contacts.position ASC')[i].email%&gt;";
          var contactV = parseInt("&lt;%=Contact.order('contacts.position ASC')[i].contact_no%&gt;";
          var posV = parseInt("&lt;%=Contact.order('contacts.position ASC')[i].position%&gt;";  
          tx.executeSql('INSERT INTO contact_table (firstname, lastname, email, contact, pos)
          VALUES (firstnameV,lastnameV, emailV, contactV, posV)');
      }
  </code></pre>