Propoerly escape ruby string for javascript

Use the to_json method to escape, then remove the extra quotes, then escape the
' symbol