# Text Output Display in Rails is OUT OF CONTROL!

**URL:** <https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211>\
**Category:** Rails\
**Created:** [February 26, 2010, 6:50pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211 "2010-02-26T18:50:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 26, 2010, 6:50pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/1 "2010-02-26T18:50:51Z")

</div>

I have a shell command statement in my controller that runs a ruby  
script and puts this text output into my instance variable which I call  
in my view.

Controller Code:  
`
@data = /usr/bin/ruby_script.rb
`

View Code:  
`
<%= @data %>
`

The problem is when @data has long strings of data, the don’t wrap in my  
view so they go off page in the browser.

How can I force long strings contained in @data to word wrap in the  
browser?  
I tried putting them in a table but that didn’t help.

Thanks

jackster

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 26, 2010, 8:19pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/2 "2010-02-26T20:19:27Z")

</div>

On Fri, Feb 26, 2010 at 9:50 AM, jackster the jackle  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a shell command statement in my controller that runs a ruby  
> script and puts this text output into my instance variable which I call  
> in my view.

> View Code:  
> `
> <%= @data %>
> `

So are you really using the CODE tag? Regardless,

> The problem is when @data has long strings of data, the don’t wrap in my  
> view so they go off page in the browser.

[http://www.w3.org/TR/CSS21/text.html#propdef-white-space](http://www.w3.org/TR/CSS21/text.html#propdef-white-space)

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 26, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/3 "2010-02-26T21:29:52Z")

</div>

“So are you really using the CODE tag? Regardless,”

Thanks Hassan,

No I’m not using these tags, I used them for the purposes of the forum  
(which didn’t help)…sorry about that confusion.

The link to that document looks like exactly what I need…it appears  
that I need to do this in my CSS file?

thanks

jackster

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 26, 2010, 10:28pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/4 "2010-02-26T22:28:48Z")

</div>

On Fri, Feb 26, 2010 at 12:29 PM, jackster the jackle  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> No I’m not using these tags, I used them for the purposes of the forum  
> (which didn’t help)…sorry about that confusion.

NP. The typical browser default for CODE tags is preformatted  
(white space is significant and retained exactly). Anyway,

> The link to that document looks like exactly what I need…it appears  
> that I need to do this in my CSS file?

Yes, apply the appropriate white-space setting to the selector for the  
container (div, p, whatever) holding that content.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 27, 2010, 1:13am UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/5 "2010-02-27T01:13:50Z")

</div>

On Fri, Feb 26, 2010 at 2:54 PM, jackster the jackle  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Yes, apply the appropriate white-space setting to the selector for the  
> > container (div, p, whatever) holding that content.
> 
> What about the fact that it’s in a table, should I put the div tags  
> outside that?

No, try applying the style directly to the container it’s in, so if  
that’s a  
TD of a table, use that.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 26, 2010, 11:54pm UTC](https://www.ruby-forum.com/t/text-output-display-in-rails-is-out-of-control/184211/6 "2010-02-26T23:54:59Z")

</div>

> Yes, apply the appropriate white-space setting to the selector for the  
> container (div, p, whatever) holding that content.

What about the fact that it’s in a table, should I put the div tags  
outside that?

thanks for the help

jackster
