# A problem of ignoring newline in textarea

**URL:** <https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169>\
**Category:** Rails\
**Created:** [January 8, 2009, 3:21am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169 "2009-01-08T03:21:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 3:21am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/1 "2009-01-08T03:21:40Z")

</div>

I use text\_area\_tag in a view page and when its action get its value by  
params[:id], all the newline will be removed. How can I keep the format  
of textarea?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 3:28am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/2 "2009-01-08T03:28:02Z")

</div>

You should not try that because the text area is designed to wrap text  
automatically - there really are not new line characters in the text  
area, unless you manually inserted them. In that case, they should  
remain.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 3:30am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/3 "2009-01-08T03:30:05Z")

</div>

srj wrote:

> You should not try that because the text area is designed to wrap text  
> automatically - there really are not new line characters in the text  
> area, unless you manually inserted them. In that case, they should  
> remain.

I have input “\n” at each line of the text, but it doesn’t work.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 3:35am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/4 "2009-01-08T03:35:39Z")

</div>

## simple\_format(your\_text\_here)

Ryan B.  
Freelancer

> **[frozenplague.net](http://frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 3:48am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/5 "2009-01-08T03:48:47Z")

</div>

Ryan B. wrote:

> ## simple\_format(your\_text\_here)
> 
> Ryan B.  
> Freelancer  
> [http://frozenplague.net](http://frozenplague.net)

In this way, I have to write \n in the textarea which is not a good user  
interface. How can I do some background job to replace the textarea  
before it is submitted?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 4:25am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/6 "2009-01-08T04:25:27Z")

</div>

Ryan B. wrote:

> no, you don’t have to write the \n.
> 
> When people type new lines it automatically puts in the \n, or in some  
> cases a \r\n.
> 
> ## This means simple\_format will work.
> 
> Ryan B.  
> Freelancer  
> [http://frozenplague.net](http://frozenplague.net)

thanks it works.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 8, 2009, 4:13am UTC](https://www.ruby-forum.com/t/a-problem-of-ignoring-newline-in-textarea/157169/7 "2009-01-08T04:13:08Z")

</div>

no, you don’t have to write the \n.

When people type new lines it automatically puts in the \n, or in some  
cases a \r\n.

## This means simple\_format will work.

Ryan B.  
Freelancer

> **[frozenplague.net](http://frozenplague.net)**
>
> This domain may be for sale!
