# Populate textarea with Multiple Newlines

**URL:** <https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550>\
**Category:** Rails\
**Created:** [April 23, 2008, 1:51am UTC](https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550 "2008-04-23T01:51:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 23, 2008, 1:51am UTC](https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550/1 "2008-04-23T01:51:42Z")

</div>

I’m having trouble pre-populationg textarea with content that has  
multiple newlines. It seems to be treating two \n characters as one  
\n character. In fact I believe we have a \r\n\r\n but for some  
reason the text area is not showing me the extra new line.

Does anyone have any suggestions?

\<%= @content %\>

where @content is:

This is paragraph one

This is paragraph two

This is paragraph three

The textarea will show:

This is paragraph one  
This is paragraph two  
This is paragraph three

Somehow it’s ignoring the multiple line breaks.

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 17, 2008, 11:36pm UTC](https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550/2 "2008-06-17T23:36:28Z")

</div>

I’d like to bump this one – I’ve googled and every answer I find wants  
to install some text formatting plugin or use a bunch of JS to fix it –  
blech!

In Lasso, this just worked. textarea-\>MySQL-\>webpage just plain worked.  
I’ve monkeyed with various regex tweaks, with and without h(), and  
somehow Ruby or Rails just wants to screw this up.

– gw

-kinetic wrote:

> I’m having trouble pre-populationg textarea with content that has  
> multiple newlines. It seems to be treating two \n characters as one  
> \n character. In fact I believe we have a \r\n\r\n but for some  
> reason the text area is not showing me the extra new line.
> 
> Does anyone have any suggestions?
> 
> \<%= @content %\>
> 
> where @content is:
> 
> This is paragraph one
> 
> This is paragraph two
> 
> This is paragraph three
> 
> The textarea will show:
> 
> This is paragraph one  
> This is paragraph two  
> This is paragraph three
> 
> Somehow it’s ignoring the multiple line breaks.
> 
> Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2008, 12:00am UTC](https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550/3 "2008-06-18T00:00:55Z")

</div>

Which browser(s) are you using. Works fine for me in Safari 3.1.1.

~ Mark

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2008, 12:14am UTC](https://www.ruby-forum.com/t/populate-textarea-with-multiple-newlines/135550/4 "2008-06-18T00:14:34Z")

</div>

On Jun 17, 2008, at 2:36 PM, Greg W. wrote:

> I’d like to bump this one – I’ve googled and every answer I find  
> wants  
> to install some text formatting plugin or use a bunch of JS to fix  
> it –  
> blech!
> 
> In Lasso, this just worked. textarea-\>MySQL-\>webpage just plain  
> worked.  
> I’ve monkeyed with various regex tweaks, with and without h(), and  
> somehow Ruby or Rails just wants to screw this up.

Ah, geeeeeezzzzz. I was using ‘\n’ instead of “\n” in some validation  
parsing.

self.moron!

– gw
