# Help with simple\_format and line breaks

**URL:** <https://www.ruby-forum.com/t/help-with-simple-format-and-line-breaks/92876>\
**Category:** Rails\
**Created:** [April 25, 2007, 9:20am UTC](https://www.ruby-forum.com/t/help-with-simple-format-and-line-breaks/92876 "2007-04-25T09:20:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![onemind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@onemind](https://www.ruby-forum.com/u/onemind)\
**Post date:** [April 25, 2007, 9:20am UTC](https://www.ruby-forum.com/t/help-with-simple-format-and-line-breaks/92876/1 "2007-04-25T09:20:20Z")

</div>

Hello Ruby forum,  
I’ve been looking at the other threads before posting this, but I can’t  
find a good solution to the problem I’m having.

The problem: in one of my views, I have the following code:

\<% for column in BlogPost.content\_columns %\>

\<%=h(simple\_format(blog\_post.send(column.name))) %\>  
\<% end %\>

This does exactly what it’s supposed to do - it preserves the line  
breaks and carriage returns entered into my text fields by adding

,  
 and suchlike. But that's all it does. If I entered:

“Please  
have  
a nice day”

into the “body” text field of my blog engine, I would get:

“Please

have

a nice day”

back (I left some HTML code out, but you get the idea).

How do I get back exactly what I entered? If you answer, would you mind  
posting some code? I still haven’t seen a code example that solves this  
problem. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![onemind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@onemind](https://www.ruby-forum.com/u/onemind)\
**Post date:** [April 25, 2007, 9:58am UTC](https://www.ruby-forum.com/t/help-with-simple-format-and-line-breaks/92876/2 "2007-04-25T09:58:26Z")

</div>

onemind wrote:

> How do I get back exactly what I entered? If you answer, would you mind  
> posting some code? I still haven’t seen a code example that solves this

This is without code… Sorry 😉  
Have a look at the incoming posting. If you enter the message directly  
into your database, it wont have any line breaks at all. If a message  
comes from a textfield on your page it will contain line breaks like  
“\n”.

bye.  
andreas

---

<div class="post-metadata">

**Author:** ![onemind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@onemind](https://www.ruby-forum.com/u/onemind)\
**Post date:** [April 27, 2007, 8:54am UTC](https://www.ruby-forum.com/t/help-with-simple-format-and-line-breaks/92876/3 "2007-04-27T08:54:35Z")

</div>

> Andreas wrote:  
> Have a look at the incoming posting. If you enter the message directly  
> into your database, it wont have any line breaks at all. If a message  
> comes from a textfield on your page it will contain line breaks like  
> “\n”.

Hi andreas,  
I feed the text into the database from a :text field in my view. I  
looked at what was stored in my tables, and it looks like it has line  
breaks. They just don’t show up in my UI. Any insights?

Thank you,  
onemind
