pretty simple question. I'm trying to use gon. I set the variable in the controller like this:
gon.preference = "hello"
and in my .js.erb file, I try to use the variable like this:
console.log(gon.preference)
but I get an error saying that "gon is not defined". What could be the problem? Obviously rails recognizes that there is a gon variable. the .js.erb file is in my assets/javascripts directory. I tried changing the file name to .js (though I didn't expect this to make a difference at all). obviously no change.
No clue why gon is just not working!
Help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…