Archive for

Assigning a Ruby expression to a Javascript variable.

I came across a problem: before directly assigning a ruby expression to a javascript variable, it’s a good idea to escape it: var my_javascript_var = ‘<%= escape_javascript(my_ruby_expression) %>’; The reason to do that is your ruby expression might contain special symbols ( for example some innocent quotes), making your life excruciatingly painful when all of … Continue reading