i have a view in my postgres database that returns an array on my frequencies
column. unfortunately, it sometimes returns values like {NULL}
(due to the raw data).
in my rails view, i have something like:
dataset = [
<% @item.each do |i| %>
{
name: "<%= i.device %>"
lng: <%= i.longitude %>
lat: <%= i.latitude %>
frequencies: <%= i.frequencies.to_s.html_safe %>
},
<% end %>
]
which appears to work great - except when it reaches a record that contains {NULL}
:
in the javascript console it shows:
Uncaught ReferenceError: nil is not defined
and in the html it shows:
...
}, {
name: "blah",
lng: -122.2,
lat: 37.4,
frequencies: [nil]
}, {
...
i could fix this by iterating through the list in the controller, but i think this would be rather long winded (and a waste of cycles).
is there a way i can get the erb to output the 'correct' []
in (instead of [nil]
) json when it's null?