views:

11

answers:

1

I use a text area to collect comments from the user. The text area preserves the next line and white space indentation. While displaying the comment in a p tag the next line and white space indentation at the beginning of the line are lost.

I enter the following text in the text area:

  Lorem ipsum dolor sit amet, 
consectetur adipisicing elit, 
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua

The form save preserves the next line in the comment.

I display the comment as:

%p #{@user.comment}

This displays the following text:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

How do I display the saved text with correct whitespaces?

+1  A: 

Use the simple_format helper

%p
  =simple_format(@user.comment)
shingara