passing rails data to javascript

Hi there
how do I pass rails data to a JS array?
arr[0] =
arr[1] = @user.location

something like that
I've been trying differente approaches but no luck so far
thanks in advance

this works for me in rhtml files:
<script type="text/javascript">
  name_id=<%= %>;

<script type="text/javascript">
  arr[0] = <%= %>


to_json is great for this.

var user_obj = <%= @user.to_json %>;

If you want an array of values:

var arr = <%= @user.values.to_json %>;

thanks a lot guys
I tried the to_json but for a lame reasson
it broke the app
webrick wont start

Weird... can you try: @user.attributes.to_json?

What's in @user?