Reputation: 48443
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?
Upvotes: 0
Views: 172
Reputation: 26979
To convert newlines to look right in html, use simple_format to convert the text.
Upvotes: 1
Reputation: 237
First of all
mess_body = params[:contact][:message]
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:
mess_body = params[:contact][:message][0]
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
Upvotes: 0