Turning <br /> into a line feed?

This seems fairly straight forward, but I’m a newbie to rails. Can I
just write a function and pass it the “comment.body” and have it return
the “comment.body” with all of the
into line feeds?

def break_to_linefeed(text)
text.gsub("
","%0")
text
end

I don’t know what the line feed code is, but will something like this
work? Or is there a better way (aside from using RedCloth)??? Thanks!

ry an wrote:

This seems fairly straight forward, but I’m a newbie to rails. Can I
just write a function and pass it the “comment.body” and have it return
the “comment.body” with all of the
into line feeds?

def break_to_linefeed(text)
text.gsub("
","%0")
text
end

I don’t know what the line feed code is, but will something like this
work? Or is there a better way (aside from using RedCloth)??? Thanks!

I’M SORRY! I meant turning a line feed into a
. So just switch
the gsub params, and that’s what I’m asking - Thanks!

text.gsub("\n","
")

\n means “newline”.

Max

ry an <rails-mailing-list@…> writes:

I’M SORRY! I meant turning a line feed into a
. So just switch
the gsub params, and that’s what I’m asking - Thanks!

You might like to look at the simple_format function

Gareth