rails array to javascript

The effect I'm trying to achieve here is basically as follows:

test_controller.rb

There is no ruby iteration here (ie this chunk of view executes from top to bottom with no looping, ie it's not the x+=1 going wrong. just that from ruby's point of view there is no loop. You either need to make that array exist in javascript land and then just iterate through it in javascript or do the iteration in your view itself (ie something like <% @array.each do |value| %>   document.write("Test - <%=value%>") <% end %>

Fred