# Break Word?

**URL:** <https://www.ruby-forum.com/t/break-word/108415>\
**Category:** Rails\
**Created:** [July 3, 2007, 9:34am UTC](https://www.ruby-forum.com/t/break-word/108415 "2007-07-03T09:34:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2007, 9:34am UTC](https://www.ruby-forum.com/t/break-word/108415/1 "2007-07-03T09:34:22Z")

</div>

On my app I allow users to post comments. I’m afraid some user might  
post something like this:

“whateveeeeeeeeeeee…eeeeeeer”

This will stretch my page and mess up my entire layout. Rails’  
break\_word helper doesn’t work in this case, so how I avoid this,  
using either Ruby or CSS?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2007, 9:54am UTC](https://www.ruby-forum.com/t/break-word/108415/2 "2007-07-03T09:54:24Z")

</div>

> On my app I allow users to post comments. I’m afraid some user might  
> post something like this:
> 
> “whateveeeeeeeeeeee…eeeeeeer”
> 
> This will stretch my page and mess up my entire layout. Rails’  
> break\_word helper doesn’t work in this case, so how I avoid this,  
> using either Ruby or CSS?

You can truncate the string to a maximun length using:

\<%= truncate(@comment\_text,max\_length) %\>

Or do by your hand some code that break long words (using a space and a  
minus) if they are longer than a length and then use word\_wrap (it takes  
the spaces into account)…
