i have a rails controller grabbing some data from mongodb. the field i’m interested in is actually an array and i would like to expose this in an erb view.
my current hack is to just set the javascript variable in the view directly (where item.array = [ “one”, “two” ]):
var array = <%= item.array %>;
however, i see that the code is coming out escaped such that the html is coming out like
var array = ["one", "two"];
is there a helper function i can use so that i can set the array directly in the javascript?
(long term is to move this into a json call, but i just want to get something working for now)
Please use as per below: