Forum: Ruby on Rails Convert \n newlines to html <br>

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
13454c212d9e3b7967f1bd6a77ae3d6b?d=identicon&s=25 Charley Ramm (charleyramm)
on 2006-03-07 00:48
I have a textarea that accepts a shipping address, so I need to convert
newlines when it is displayed as html. I am new to ruby, and rails so an
example would be appreciated. I want to do this in the 'display', not
the stored text if possible, since I use the newlines when generating a
pdf.
Thanks.
 charley
00e3a96684ab390a350b0271e98741d3?d=identicon&s=25 Nshbrown Nshbrown (nshb)
on 2006-03-07 03:14
(Received via mailing list)
<%= address.gsub(/\n/, '<br />') %>

-Nb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Nathaniel S. H. Brown                           http://nshb.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337cdd270761e0e6f4356de45b04d388?d=identicon&s=25 Jonathan Viney (jonny)
on 2006-03-08 01:55
Or use RedCloth:

gem install redcloth

textilize(address)

You can do as much formatting as you like.

http://whytheluckystiff.net/ruby/redcloth/

-Jonny.
This topic is locked and can not be replied to.