Carriage return retrievel using RoR

Hi

If I have for example:

Test 1

Test 2

in the field result in the picture table in my database, then using
@picture.result I get:

Test 1 Test 2

i.e. the carriage return is missing. Does anyone know an easy way to
overcome this so that my preview is correct?

Many thanks

Darren

i.e. the carriage return is missing. Does anyone know an easy way to
overcome this so that my preview is correct?

Perhaps make a helper and do the following:

in application helper:
def format_text(text)

” << h(text).gsub(/\n/,"

") << “


end

in view:

<%=format_text(@picture.result)%>

Luke P. <rails-mailing-list@…> writes:

There’s already a helper in Rails to do this…

<%= simple_format @picture.result %>

Darren E. wrote:

i.e. the carriage return is missing. Does anyone know an easy way to
overcome this so that my preview is correct?

No need to create a special helper. Rails already has one!

In your view:

<%= simple_format @picture.result %>

See
http://api.rubyonrails.com/classes/ActionView/Helpers/TextHelper.html#M000513