method
escape_javascript
escape_javascript(javascript)
public
Escapes carriage returns and single and double quotes for JavaScript segments.
Also available through the alias j(). This is particularly helpful in JavaScript responses, like:
$('some_element').replaceWith('<%= j render 'some/element_template' %>');