I have a simple form, where a user can write some text and this text will be send to his email. This process works fine, but I have a problem with the text, that user wrote – in the email is displayed following:
["sadgsdah\r\nsdh\r\ndsf\r\nh\r\nfdhdfhdfh\r\n\r\n\r\n\r\nfdh\r\ndf\r\njh"]
why there are the brackets and the \n and \r chars?
Before than I give the variable with the content into the email template, I tried to do following:
mess_body = params[:contact][:message].to_s.html_safe
But unfortunately this didn’t help me… what I am doing wrong?
First of all
returns a array, not a single thing. That is why you get the [” and “] around the output.
you could get the first element like this:
Furthermore \n\r are line endings of a text box. Assuming that the e-mail you’re sending is HTML the \n\r should be replaced by <br> in the String