# How to save break line in text (at my model)?

**URL:** <https://www.ruby-forum.com/t/how-to-save-break-line-in-text-at-my-model/210769>\
**Category:** Rails\
**Created:** [August 16, 2011, 11:57pm UTC](https://www.ruby-forum.com/t/how-to-save-break-line-in-text-at-my-model/210769 "2011-08-16T23:57:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 16, 2011, 11:57pm UTC](https://www.ruby-forum.com/t/how-to-save-break-line-in-text-at-my-model/210769/1 "2011-08-16T23:57:46Z")

</div>

If anyone can help me please do.

Thank you,  
Rodrigo

---

<div class="post-metadata">

**Author:** ![dracko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c89c15/32.png) [@dracko](https://www.ruby-forum.com/u/dracko)\
**Post date:** [August 17, 2011, 6:22pm UTC](https://www.ruby-forum.com/t/how-to-save-break-line-in-text-at-my-model/210769/2 "2011-08-17T18:22:49Z")

</div>

Rodrigo R. wrote in post #1017036:

> If anyone can help me please do.

I’m guessing about the meaning of your question, which is oddly in the  
subject of this post rather than the body of the post, but I assume you  
mean to say that you have a text area where the visitor can type  
multiple lines of text that gets stored into the database with  
appropriate new line (i.e. \n) characters.

It’s not that the new line characters are not “saved” as you phrased it,  
but rather that HTML treats all whitespace (i.e. Space, Tab, Carriage  
Return, Line Feed, etc.) as a single space character.

This simplest solution is to replace LF (or CRLF) characters with the  
HTML   
 tag. Fortunately Rails provides a view helper for this  
purpose called simple\_format:

> **[simple\_format(text, html\_options = {}, options = {}) Link -...](https://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format)**
>
> Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines (\\n\\n or \\r\\n\\r\\n) are considered a paragraph and wrapped in \<p\> tags. One newline (\\n or \\r\\n) is considered a linebreak and a \<br /\> tag is appended....

---

<div class="post-metadata">

**Author:** ![dracko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c89c15/32.png) [@dracko](https://www.ruby-forum.com/u/dracko)\
**Post date:** [August 17, 2011, 8:26pm UTC](https://www.ruby-forum.com/t/how-to-save-break-line-in-text-at-my-model/210769/3 "2011-08-17T20:26:30Z")

</div>

thank you, it worked
