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

后端 未结 8 1293
情书的邮戳
情书的邮戳 2020-12-04 11:30

Is there a Railsy way to convert \\n to
?

Currently, I\'m doing it like this:

mystring.gsub(/\\n/, \'
\')
8条回答
  •  醉酒成梦
    2020-12-04 11:37

    You also might consider what you're trying to do - if you're nicely formatting text that people have entered, you might consider a filter like Markdown to let your users format their text without opening up the can of worms that is HTML. You know, like it is here at Stack Overflow.

提交回复
热议问题