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

If you are outputting as HTML, you'd have to replace carriage return/line feed with a <br /> 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.




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.


my_text = “”"Here is some basic text…

        ...with a line break."""


=> “

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

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

          ...right there."""


=> “

We want to put a paragraph…

…right there.

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