# Html format

**URL:** <https://www.ruby-forum.com/t/html-format/107288>\
**Category:** Rails\
**Created:** [June 20, 2007, 6:53am UTC](https://www.ruby-forum.com/t/html-format/107288 "2007-06-20T06:53:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 6:53am UTC](https://www.ruby-forum.com/t/html-format/107288/1 "2007-06-20T06:53:28Z")

</div>

Hi, i have a text field in html format “It is a sunny   
day.   
 Bye”  
When i put in the rhtml  
\<%= news.text\_field %\>  
I get printed the text with the tags inside…  
is there a to\_html or soemthing like that?

thanks

Christian

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 6:58am UTC](https://www.ruby-forum.com/t/html-format/107288/2 "2007-06-20T06:58:28Z")

</div>

On 6/20/07, cfingerh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Christian

You may need to provide some more information about what your trying to  
do.

An HTML Text field, or textarea will not render as html. They only  
contain  
text. Perhaps something like tinyMCE or similar javascript powered rich  
editor is what your after.

Daniel

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 7:10am UTC](https://www.ruby-forum.com/t/html-format/107288/3 "2007-06-20T07:10:29Z")

</div>

I will try to explain it better…  
It is not for editing or creating a text. I already have the text in  
my table-database

I have  
\<% for new in @news %\>  
Title:

# \<%= new.title.to\_s %\>
  
  
  
\<%= new.title.text %\>  
  
  
\<%end\>

And the text field has html tags inside (divs and spans)  
The result is that the text printed is with the tags.For example

```
          Title: New Member in the Society
          The society wants to <span class="bold">announce</span>

```

that:   
 Mr etc, etc  
Title: New Member in the Society  
The society wants to announce  
that:   
 Mr etc, etc

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 7:31am UTC](https://www.ruby-forum.com/t/html-format/107288/4 "2007-06-20T07:31:31Z")

</div>

sorry…

\<%= new.text %\>

text is the name of the field

thanks

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 7:29am UTC](https://www.ruby-forum.com/t/html-format/107288/5 "2007-06-20T07:29:30Z")

</div>

On 6/20/07, cfingerh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> <%= new.title.text %>
> The society wants to <span class="bold">announce</span>
> 
> ```
> 
> that:   
> Mr etc, etc

Where does the text method come from in this line?  
\<%= new.title.text %\>

It seems that title is an attribute of the AR model, but there is no  
text  
method that I know of on String. What kind of object is it?

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 7:39am UTC](https://www.ruby-forum.com/t/html-format/107288/6 "2007-06-20T07:39:34Z")

</div>

On 6/20/07, cfingerh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> sorry…
> 
> \<%= new.text %\>
> 
> text is the name of the field
> 
> thanks

Cool. That makes more sense to me.

There is nothing imediate that jumps to mind except that at some point  
it  
seems that the tags are being escaped.

If you select these directly from the database, or using the console.  
Is  
the markup like

The society wants to announce  
that:   
 Mr etc, etc

Or is the tags escaped? Like

The society wants to \<span class=“bold”&gr;announce\</span\>  
that: \<br\> Mr etc, etc

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 10:22am UTC](https://www.ruby-forum.com/t/html-format/107288/7 "2007-06-20T10:22:48Z")

</div>

I get it printed like  
The society wants to announce  
that:   
 Mr etc, etc

but in the Page Source it is tags escaped …

The society wants to \<span class=“bold”&gr;announce\</span\>  
that: \<br\> Mr etc, etc

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 11:06am UTC](https://www.ruby-forum.com/t/html-format/107288/8 "2007-06-20T11:06:54Z")

</div>

I found the problem.

I had  
\<%=h new.text %\>

not  
\<%= new.text %\>

Anyway thank you very much Daniel

---

<div class="post-metadata">

**Author:** ![cfingerh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f14d63/32.png) [@cfingerh](https://www.ruby-forum.com/u/cfingerh)\
**Post date:** [June 20, 2007, 10:21am UTC](https://www.ruby-forum.com/t/html-format/107288/9 "2007-06-20T10:21:48Z")

</div>

In the screen I get it  
The society wants to announce  
that:   
 Mr etc, etc

The society wants to \<span class=“bold”&gr;announce\</span\>  
that: \<br\> Mr etc, etc
