# HTML tags in database

**URL:** <https://www.ruby-forum.com/t/html-tags-in-database/70479>\
**Category:** Ruby\
**Created:** [September 29, 2006, 3:36pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479 "2006-09-29T15:36:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 3:36pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/1 "2006-09-29T15:36:22Z")

</div>

I put html tags in a longtext field in my database, but when I grab it  
for the page it uses it as regualr text. How can I get the html tags  
to be recognized?

---

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 5:10pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/2 "2006-09-29T17:10:53Z")

</div>

On 9/29/06, Amos K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I put html tags in a longtext field in my database, but when I grab it  
> for the page it uses it as regualr text. How can I get the html tags  
> to be recognized?

Can you show some specifc code please? There isn’t enough context  
here for us to help you.

---

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 5:14pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/3 "2006-09-29T17:14:54Z")

</div>

Amos K. wrote:

> I put html tags in a longtext field in my database, but when I grab it  
> for the page it uses it as regualr text. How can I get the html tags  
> to be recognized?

You are probably escaping “\<”, “\>” and “&”. Just don’t do that.

---

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/4 "2006-09-29T17:18:55Z")

</div>

On 9/29/06, Gregory B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 9/29/06, Amos K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I put html tags in a longtext field in my database, but when I grab it  
> > for the page it uses it as regualr text. How can I get the html tags  
> > to be recognized?
> 
> Can you show some specifc code please? There isn’t enough context  
> here for us to help you.

sure

| \<%= post.body %\> |

body may look like:

Hello, I’m a link!

I want the html to be interpreted, but it is showing up as text in my  
browser so link is not a link.

---

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/5 "2006-09-29T21:47:37Z")

</div>

I put html tags in a longtext field in my database, but when I grab it  
for the page it uses it as regualr text. How can I get the html tags  
to be recognized?

rhtml looks like:

| \<%= post.body %\> |

body may look like:

Hello, I’m a link!

output:

Hello, I’m a link!

I want the html to be interpreted, but it is showing up as text in my  
browser so link is not a link.

Does anyone know of a way to accomplish this.

Thanks  
Amos

---

<div class="post-metadata">

**Author:** ![thekernel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thekernel](https://www.ruby-forum.com/u/thekernel)\
**Post date:** [September 29, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/html-tags-in-database/70479/6 "2006-09-29T22:09:40Z")

</div>

On 9/29/06, Amos K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello, I’m a link!

Look at the source code.

You might be actually getting \<
