I'm trying to turn a ruby array into a js array in a js.erb file. I've checked all questions on this in stack overflow but it isn't working for me.
Here is the function
function c(c) {
js_array = <%= raw @keys.to_json %>;
b.selection.remove(), b.html.insert('js_array[0]');
}
It throws the error Uncaught TypeError: Cannot read property '0' of null
Im still learning js so im not sure what is going wrong here
The ruby @keys array defiantly has data in it because I'm printing that on the same page.
And if i change the array to js_array = ['gwfe', 'efw', 'efwe']; it works fine. This makes me believe something is going wrong when trying to convert the ruby array into a js array.