Topic: Word_wrap not wrapping?

Hello,

I seem to be having some difficulties with the word_wrap text helper.  In my view I have something that goes a little like this...

<%= word_wrap(@sample.description, line_width = 40) %>

Which really ought to be a textbook example of the word wrap function.  However, the description (@sample.description) is displayed unwrapped.  There aren't any errors or other difficulties that I can see, the word_wrap helper is just displaying the text without doing anything to it.  Is there something I'm missing?  The helper for truncate() worked just fine, so I'm reasonably certain there's nothing particularly boneheaded with my syntax.

Re: Word_wrap not wrapping?

The word_wrap method adds normal line breaks, not HTML <br /> tags. Try wrapping that in simple_format to get it to add line breaks in HTML.

<%= simple_format word_wrap(@sample.description, 40) %>

Last edited by ryanb (2006-08-08 13:55:08)

Railscasts - Free Ruby on Rails Screencasts