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.
@testvariable could contain a value that creates invalid JavaScript so then it would stop before it gets to thedocument.write(). Yourdocument.write("somethinganything")should work, as you can see here: jsfiddle.net/Aa5nn, unless you have it after the samevar test = ...line with an error.var test ...line due to some syntax error and never makes it to the followingdocument.writeline