0
我有一個串記錄@user.location
說我打印到ERB文件,我想它改爲:如何將新行插入到SQL/Rails字符串記錄中?
"first line
second line"
到目前爲止,我已經試過:
@user.location = "first line" + "\n" + "second line"
@user.location = "first line" + '\n' + "second line"
@user.location = "first line" + "<br />" + "second line"
@user.location = "first line" + '<br />' + "second line"
@user.location = "first line
second line"
但他們所有最終都會打印文字字符而不是換行符。我怎樣才能做到這一點?
你想在哪裏輸出它?它運行得很好,用'puts'第一行「+」\ n「+」第二行「' – kirqe
@railsr有沒有一種方法可以通過編寫'<%= @ user.location%>來在erb中輸出換行符' ? –