Rails — Add a line break into a text area

前端 未结 11 986
南旧
南旧 2020-12-12 10:21

I got a rails app where I can input a few paragraphs of text into my model. The problem is I dont know how to input any line breaks.

I\'ve tried to add \" {ln}{/ln}

11条回答
  •  -上瘾入骨i
    2020-12-12 11:23

    What version of rails are you using?? Because the way to handle this, is different in rails 2 and 3.

    Let's say the value of the record is "foo
    bar"

    In rails 3, if you want to evaluate the html, you could do <%=raw "foo
    bar" %>
    , if you do so, you'll get a line break when you will see the view.

    In rails 2 you don't have to do that, just do <%= "foo
    bar" %>

    Also, HTML doesn't get evaluated in a textarea anyway.

提交回复
热议问题