Preserving the format of text field data

Hello all,

I’m still fairly new to RoR. Had a question related to a form’s text
field data. Given a blog model for example, with fields: title, date
and body. If I were to type a full body’s worth of text with line
breaks and such, much like I am doing now within this message field of
the post. How would I be able to preserve the original typed in
format without resorting to the use of the

 html element within
the view template or having to input data in the field using


html elements?

I tried to glean off any information from the “Blog in 15 mins”
railscast @, but David only posted one sentence data
in each body field. So nothing much to go on there.


Rails is preserving all the line breaks and so forth when the text is
written to the database. But when you display this text on a web page,
is in interpreted as HTML, which collapses multiple spaces to one, and
ignores line breaks.

Somehow you need to get HTML tags marking up your text. My preferred
way to do this is to use Textile markup for the text, and then Textile
will create the HTML markup for you.

Here’s an article that explains how to use Textile:

Michael S.