Preserving whitespace & line breaks

I have a text field that submits stuff to my database. When I display
this data, it no longer has line breaks, everything is just in one big
row. How can I preserve my whitespace and line breaks?

I have a text field that submits stuff to my database. When I display
this data, it no longer has line breaks, everything is just in one big
row. How can I preserve my whitespace and line breaks?

It won’t keep it from crunching multiple spaces into one though… if
you
really need it as is, wrap it in

 or  or convert all the
spaces
to  …

-philip

Philip H. wrote:

http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M000516

sanitize? I’m using it now to process output text but line breaks are
still screwed.

Philip H. wrote:

http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M000516

sanitize? I’m using it now to process output text but line breaks are
still screwed.

simple_format.

Sorry, wasn’t very clear on that…

simple_format(text)
Returns text transformed into HTML using very simple formatting rules
Surrounds paragraphs with

tags, and converts line breaks into

Two consecutive newlines(\n\n) are considered as a paragraph, one
newline
(\n) is considered a linebreak, three or more consecutive newlines are
turned into two newlines

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs