I have the following in a html.erb file:
<%= @location_list = [['test',2]] %>
<script type="text/javascript">
var test = <%= @location_list.to_json %>
alert(test);
</script>
And the alert is not showing up.
However if I do <%= @location_list = [[3,2]] %> – The alert is showing up.
Why?
<%= %> tag means output something. In your case, you probably dont want to output anything, so I guess you are looking for
<% @location_list = [[‘test’,2]] %>, which means normal statement no output will be involved
Sorry, havn’t really answer your question.
should be