In the docs it says that to put JavaScript into Arbre you must use script { raw ... }
. At first I understood from this to write script { raw [insert code here]}
. With the word raw as being part of it. That didn't work. So then I thought it might be that it was script {[insert code here]}
, but that also didn't work. I am writing the code as a string because if I try to write it directly, Ruby says the code is not ruby code and accuses an error. But when I look into the HTML with Inspect, the JS code appears almost perfectly there, except that wherever I put quotation marks, instead it is written "
, and I don't know how to make it so it actually places quotations properly.
Does anyone know what I am doing wrong?
Thanks in advance!
One way:
Another way:
Then in
app/views/shared/_myjavascript.html.erb
place the following: