In Rails – is there a rails method to convert newlines to ?

Yes, rails has simple_format which does exactly what you are looking for, and slightly better since it also adds paragraph tags. See

http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-simple_format

Example:

 simple_format(mystring)

Note that simple_format allows basic HTML tags, but also passes text through sanitize which removes all scripts, so it should be safe for user input.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)