Report abuse

in your controller


			
def foos_for_lookup
  @foos = Foo.find(:all)
  @headers['content-type' ] = 'text/javascript'
  render :layout => false
end

in your view foos_for_lookup.rhtml


			
var foos = new Array(<%= @foos.size %>);
<% @foos.each_with_index do |foo, i| %>
  foos[<%= i %>] = "<%= foo.name %>" ;
<% end %>

then in your main view