I use rails 3.0.3
A javascript auto complete needs data like this
{
query:\'Li\',
suggestions:[\'Liberia\',\'Libyan Arab Jamahiriya\',\'Liechtenstein\'
I've seen something like this in a .erb:
<%= raw
{
:query => @query,
:suggestions => @customers.map{|c| "#{c.firstname} #{c.lastname}" },
:data => @customers
}.to_json
%>
If thinking of preparing data to be consumed by other programs as presentation logic, this might make sense to you.
FWIW I like it.