Forum: Ruby on Rails word wrap ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ae73078ae3e573111012b14d38b8d3b2?d=identicon&s=25 Manu J (Guest)
on 2007-01-08 07:07
(Received via mailing list)
Hi,

I have long lines of text stored in a DB without line breaks. Now I
need to present it in
fixed width with word wrap. I tried everything css (word-wrap:
break-word;), the rails actionview helper (word_wrap), specifying
width of the div etc. But nothing works. The reason I'm
asking the question here because to me word_wrap was created to solve
this exact problem
but it is failing to do so. Correct me if i'm wrong.

Regards
Manu
9cb4de6b61b568a8c13d866ccf3b3433?d=identicon&s=25 Dan Poynor (Guest)
on 2007-01-08 07:29
Maybe this approach could work...

<p style="width:400px;"><%= @quote.statement %></p>

DAN
2d0d904abb31102b049ad60e47c7af8e?d=identicon&s=25 Bart Gajderowicz (bart)
on 2007-01-08 21:40
(Received via mailing list)
Do they have white space between the words?
Silly question, but it sounds strange that what you're doing already
doesn't work.

The following post shows how to split long words (Gregory's code is
much nicer then mine)
http://groups.google.com/group/rubyonrails-talk/br...

Bart
5e75f4b81923cd04a5c8fffa290be92e?d=identicon&s=25 Carl Johnson (carlivar)
on 2007-01-08 23:45
have you tried simple_format()?
72f8ab180f81f9c544e2b58da399c0be?d=identicon&s=25 Elad Meidar (eizesus)
on 2007-01-09 00:22
Carl Johnson wrote:
> have you tried simple_format()?

or simply word_wrap(text, line_length) ?
Ae73078ae3e573111012b14d38b8d3b2?d=identicon&s=25 Manu J (Guest)
on 2007-01-09 06:42
(Received via mailing list)
http://groups.google.com/group/rubyonrails-talk/br...

Unfortunately that did not solve the problem :(. That code splits
strings. In my case I have a paragraph on a single line without line
breaks. Yes the words have white spaces between them :).

Regards
Manu
2d0d904abb31102b049ad60e47c7af8e?d=identicon&s=25 Bart Gajderowicz (bart)
on 2007-01-09 07:57
(Received via mailing list)
This is strange indeed.  Can you give an example of text which doesn't
wrap.  It's really a basic thing in a browser.  How is your text field
defined, how is it pulled and presented via Rails?  Do you have it
online we can see?  I feel there's something else that's screwing it
up.

Bart
Ae73078ae3e573111012b14d38b8d3b2?d=identicon&s=25 Manu J (Guest)
on 2007-01-09 08:36
(Received via mailing list)
Solved :)

I was putting together a simple app to demonstrate this and the bug
disappeared.
Then I went and dug deeper. One of the parent elements was setting
white-space: nowrap.
I was not familiar with the css and was certainly not aware of the
white-space attribute.
Sorry for wasting your time.

Regards
Manu
2d0d904abb31102b049ad60e47c7af8e?d=identicon&s=25 Bart Gajderowicz (bart)
on 2007-01-09 15:57
(Received via mailing list)
Glad you got it working..
Bart
This topic is locked and can not be replied to.