Formatting a Text or CharVar(255) data type with Carriage Return or [enter]

Is there a way to format a Text or CharVar data field to include the
carriage return or [ENTER] ??

Example i saved a data as follows:

This is Line 1
Line 2
Line 3

Can I be able to display them again like that? coz right now I a wish
to display them again it’ll be shown like this:

This is Line 1 Line 2 Line 3

On Feb 17, 2008, at 7:32 PM, Ronartos wrote:

Can I be able to display them again like that? coz right now I a wish
to display them again it’ll be shown like this:

This is Line 1 Line 2 Line 3

If you are outputting as HTML, you’d have to replace carriage return/
line feed with a
tag. There’s probably a nice railsy way to
do it, but I wrote myself a little helper function that does it using
gsub! .

On the other hand, if you are capturing the data in a textarea and
output it to a textarea, you shouldn’t have to do anything.

DISCLAIMER: I haven’t been up very long this morning, so I might not
be thinking clearly.

Peace,
Phillip

string.gsub(“\n”,“
”)

On Feb 18, 2008 10:46 PM, Phillip K. [email protected]
wrote:

If you are outputting as HTML, you’d have to replace carriage return/
Peace,
Phillip


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

On 18 Feb 2008, at 13:16, Phillip K. wrote:

If you are outputting as HTML, you’d have to replace carriage return/
line feed with a
tag. There’s probably a nice railsy way to
do it, but I wrote myself a little helper function that does it using
gsub! .

On the other hand, if you are capturing the data in a textarea and
output it to a textarea, you shouldn’t have to do anything.

DISCLAIMER: I haven’t been up very long this morning, so I might not
be thinking clearly.

http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html

simple_format(text)
Returns text transformed into HTML using simple formatting rules. Two
or more consecutive newlines(\n\n) are considered as a paragraph and
wrapped in

tags. One newline (\n) is considered as a linebreak
and a
tag is appended. This method does not remove the
newlines from the text.

Examples

my_text = “”“Here is some basic text…
…with a line break.”“”

simple_format(my_text)

=> “

Here is some basic text…
…with a line break.

more_text = “”"We want to put a paragraph…

           ...right there."""

simple_format(more_text)

=> “

We want to put a paragraph…

…right there.

simple_format seems to put paragraphs where I don’t want paragraphs
sometimes.