Gaetan Dubar Gaetan Dubar - 1 year ago 95
Ruby Question

Render multiline text with Rails?

I'd like to render multiline text in Rails, the action looks like:

def mutli_text
render :text => 'Word1\nWord2'

and I'd expect the response to be :


unfortunatly I get Word1\nWord2

Any help would be appreciated

(The action must render a multiline response to get the autocomplete jquery plugin working)

Answer Source

You have to use double quotes to be able to use escaped characters.

But if you want to have that actually be a line break in the browser, you need to make it an actual html tag.


Or even:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download