I’m using Rails 4.2.7. I would like to take my hash created in Rails and output a Javascript variable that contains the hash (same data associations). So I have this in my view
var my_object_names = <%=h my_object_name_hash.to_json %>;
but what is output is
var my_object_names = {"1403913600000":"Proudun","1437782400000":"BTN Event","1466812800000":"Proud"};
This results in a Javascript error, “SyntaxError: Unexpected token &”. What is a more elegant way to take a Ruby hash and output Javascript that contains the same data?
hafter<%=?