Posted by Neelkanth Ram on September 12th, 2009

In Rails view, if you want to retain and display newline characters that was entered by the user in text area, then the simple solution to use simple_format .

If you use <%= @profile.description %> , then the carriage returns gets discarded.
The simple way is to use <%= simple_format(@profile.description) %>.

Text entered by user in a textarea field:
textarea1

Output shown as single block sentences without any wrapper.
output1

Output when the ActionView helper method simple_format is used:
output2

pixelstats trackingpixel Tags: , ,
Unique Views: 456 Total views: 615
Follow responses at RSS 2.0. Leave a response | Trackback.

    Leave a Reply