I want to make sure a javascript variable is getting the correct values passed into it when setting it to a ruby variable.
<script type="text/javascript" charset="utf-8">
var test = <%= @test || 'null' %>;
document.write(test);
</script>
However, there doesn’t seem to be any output whatsoever. I’ve tried just document.write("somethinganything") and I still don’t see any output. Is it supposed to appear on webpage or terminal? I couldn’t find any in both.
document.writeprints to the webpage. You should try usingconsole.logto print to the terminal.