Help on sending an array in ruby to javascript method

hi all,

I am new to ruby on rails and doing a small application as I am
learning ruby on rails..

Problem:
Basically I want to send an array @all_languages to a javascript method
..... and be able to access the array in it...

Details:
  I have an array of (language_name,language_id) pairs in variable
@all_languages
Eg: [ ( English, 1 ) , ( French, 2 ) , ( German, 3 ) ] ...

I am displaying every language as a row in a table

I have a link called add_lang_row which calls a javascript code to
dynamically add a new row with language_name select box

the javascript code add_lang_row takes a parameter of array of
languages described above ie array of (lang_name, id ) pair which is
used to fill the select options...[ this is working fine given my
parameter is proper ]

But I cant call the script as

  <a href='javascript' onclick='add_lang_row( <%= all_languages
%>)'>Add country</a>

so i tried ...

   <script>
            var list_of_langs;
            <% for i in 1..@all_languages.length %>
            list_of_langs[<%= i-1 %>][0] = <%=@all_languages[i-1][0]%>
            list_of_langs[<%=i-1%>][1] = <%=@all_languages[i-1][1]%>
    </script>

I am getting syntax error .. :frowning:
I am sure ruby will have some cool way of doing this .. as with habtm
etc etc...

can anyone help me here...