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:
Output shown as single block sentences without any wrapper.
Output when the ActionView helper method simple_format is used:
One Reply to “Retain Newline Characters on Rails View”
great ! thanks a bunch