passing rails data to javascript

Hi there how do I pass rails data to a JS array? like arr[0] = @user.name 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=<%= @name.id %>; </script>

<script type="text/javascript">   arr[0] = <%= @user.name %> </script>

HTH

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?