converting a ruby array to javascript array

I have this code within a javascript function:

  function load(test) {             var coordinates = new Array();             coordinates = <%= params[:coordinates] %>         }

the params contains an array with double digit numbers such as [24,45], but when it is converted within the javascript function, it turns into one long number, i.e. 2445. I found this by doing an alert() with the result. I don't really know much about javascript, so Im not sure if this is an integer or a string or what, but ultimately I need to get these original two digit numbers separated and into a javascript array. I tried performing some javascript string operations but they do not seem to be working. Any one have any ideas here? Thanks, Dave

there are two functions: array_or_string_for_javascript options_for_javascript

have a look at the source first one, it's basically doing: "['#{option.join('\',\'')}']"

joining the array elements to a string

to_json would also work:

<%= params[:coordinates].to_json %>

cool, yea array_or_string_for_javascript works well: var coordinates = <%= array_or_string_for_javascript(params[:coordinates])%>