A: 

You could write a javascript escape helper:

def escape_javascript(javascript)
        javascript.gsub!("\r\n", "\\n")
        javascript.gsub!(/\n|\r/, "\\n")
        javascript.gsub(/["']/) {|m| "\\#{m}"} || javascript
end

and call it when you save your review.

MickTaiwan
this would save it to the database in an escaped format right? seems less than ideal, since it would require unescaping it any time it was displayed in the view, right?
Brian Armstrong
unescaping would not be necessary if you escape it in HTML like escaping " into " or \r\n into <br>.See http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php
MickTaiwan
I think unescaping would not be necessary to display the html on a page, but if they go back to edit the text they wrote, they will want to edit the exact text they wrote. Found a solution below that worked...but thanks for the response, I appreciate it!
Brian Armstrong
A: 

Found a solution which worked. I'm not really sure why it worked but it did.

A couple times up above I call a partial to render the text area and form where the user can edit their review, like this

<%= render :partial => "reviews/text_area" %>

All I had to do was go in and edit this partial. One of lines in the form looked like this:

<%= f.text_area :review %>

All I did was change it to this:

<textarea cols="40" id="rating_review" name="rating[review]" rows="20"><%=@user_rating.review%></textarea>

Basically just put it in manually so it didn't use the rails function to generate the text area. For whatever reason, it works now. May be something that could be improved in the rails text_area function.

Brian Armstrong