Forum: Ruby on Rails A problem of ignoring newline in textarea

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Zhao Y. (Guest)
on 2009-01-08 04:21
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?
srj (Guest)
on 2009-01-08 04:28
(Received via mailing list)
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.
Zhao Y. (Guest)
on 2009-01-08 04:30
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.
Ryan B. (Guest)
on 2009-01-08 04:35
(Received via mailing list)
simple_format(your_text_here)
-----
Ryan B.
Freelancer
http://frozenplague.net
Zhao Y. (Guest)
on 2009-01-08 04:48
Ryan B. wrote:
> simple_format(your_text_here)
> -----
> Ryan B.
> Freelancer
> 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?
Ryan B. (Guest)
on 2009-01-08 05:13
(Received via mailing list)
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
Zhao Y. (Guest)
on 2009-01-08 05:25
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

thanks it works.
This topic is locked and can not be replied to.