# Displaying ruby content in rhtml

**URL:** <https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798>\
**Category:** Rails\
**Created:** [January 3, 2009, 1:02am UTC](https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798 "2009-01-03T01:02:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrikantv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@shrikantv](https://www.ruby-forum.com/u/shrikantv)\
**Post date:** [January 3, 2009, 1:02am UTC](https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798/1 "2009-01-03T01:02:08Z")

</div>

Hi everyone,

I am a newbie to RoR. I installed the Instant Rails package 1.7, and  
with scaffold, I was able to create and connect to a database.  
However, when I embed some code in rhtml(list.rhtml in the tutorial  
there), it does not display in browser. I can see the html part on the  
screen without problem, but the ruby part does not get processed at all.  
When I try a simple rhtml file such as below,

All Recipes
- Addition: \<% print "World!" %\> 

# Online Cookbook - All Recipes

all I can see is  
Addition:  
Online Cookbook.

I think this has something to do with eruby or erb, but do not know how  
to proceed.

Any help would be much appreciated!

Thanks  
Shrikant

---

<div class="post-metadata">

**Author:** ![shrikantv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@shrikantv](https://www.ruby-forum.com/u/shrikantv)\
**Post date:** [January 3, 2009, 1:09am UTC](https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798/2 "2009-01-03T01:09:35Z")

</div>

On 3 Jan 2009, at 00:02, Shrikant Sv wrote:

> 

\<% puts … %\> or \<% print …%\> achieves very little (at best it will  
output to your server’s log file).  
You need to be using \<%= which inserts the result of evaluating it’s  
contents, ie \<%= Time.now %\>

Fred

---

<div class="post-metadata">

**Author:** ![shrikantv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@shrikantv](https://www.ruby-forum.com/u/shrikantv)\
**Post date:** [January 3, 2009, 2:12am UTC](https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798/3 "2009-01-03T02:12:47Z")

</div>

Shrikant,

\<% %\> is code that is executed, but not displayed in the browser.  
\<%= %\> is code that will be executed and displayed.

Hope that helps!

Ethan Gunderson

On Fri, Jan 2, 2009 at 6:02 PM, Shrikant Sv

---

<div class="post-metadata">

**Author:** ![shrikantv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@shrikantv](https://www.ruby-forum.com/u/shrikantv)\
**Post date:** [January 3, 2009, 3:52am UTC](https://www.ruby-forum.com/t/displaying-ruby-content-in-rhtml/156798/4 "2009-01-03T03:52:14Z")

</div>

Just an example of both usages

\<% if is\_admin? do %\>

# \<%= admin\_title %\>
\<% end %\>
