ruby on rails - Add new line using /n in text variable -


i have variable in view printed on screen

<%= comment.comment %> 

but output has many new line characters (\n).

how print new lines whenever have \n comment.comment output?

try this:

<%= comment.comment.gsub(/\n/, '<br />') %> 

else can use simple_format. here:

<%= simple_format(comment.comment) %> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -