# Ruby on Rails image problem

**URL:** <https://rubytalk.org/t/ruby-on-rails-image-problem/21056>\
**Category:** ruby-talk\
**Created:** [24 September 2005 10:11 UTC](https://rubytalk.org/t/ruby-on-rails-image-problem/21056 "2005-09-24T10:11:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@Nick1](https://rubytalk.org/u/Nick1)\
**Post date:** [24 September 2005 10:11 UTC](https://rubytalk.org/t/ruby-on-rails-image-problem/21056/1 "2005-09-24T10:11:40Z")

</div>

hey, i am new to ruby, and i want to try this out  
just showing all the products from the database with there image

this is the code:

\<html\>  
\<head\>  
\<title\>All Recipes\</title\>  
\</head\>  
\<body\>

\<h1\>Catalogus\</h1\>  
\<table cellspacing="0" border="0"\>

\<% @products.each do |product| %\>  
\<tr class="productnaam"\>  
&nbsp;&nbsp;\<td width="450px" class=""\>\<%= link\_to [product.name](http://product.name), :action =\> "show",  
:id =\> [product.id](http://product.id) %\>\</td\>  
&nbsp;&nbsp;\<td align="right"\>\<%= link\_to "\<img src='details.gif' /\>", :action =\>  
"show", :id =\> [product.id](http://product.id) %\>\</td\>  
\</tr\>  
\<tr\>  
&nbsp;&nbsp;\<td\>\<b\>Prijs/stuk:\</b\> ? \<%= product.price %\>\</td\>  
&nbsp;&nbsp;\<td align="right"\>  
&nbsp;&nbsp;&nbsp;\<img src="\<%= product.image %\>" alt="\<%= [product.name](http://product.name) %\>"  
class="catalogus"/\>  
&nbsp;&nbsp;\</td\>  
\</tr\>  
\<% end %\>

\</table\>

\<p\>\<%= link\_to "Create new recipe", :action =\> "new" %\>\</p\>  
\<img src="details.gif"/\>  
\</body\>  
\</html\>

i cant get the image to show, how must u do that, even an regular image, and  
where do i need to put the files???

thanks in advance

---

<div class="post-metadata">

**Author:** ![Guilhem\_Vellut](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@Guilhem\_Vellut](https://rubytalk.org/u/Guilhem_Vellut)\
**Post date:** [24 September 2005 11:51 UTC](https://rubytalk.org/t/ruby-on-rails-image-problem/21056/2 "2005-09-24T11:51:40Z")

</div>

You can put all your images inside public/images, which is created by  
the rails command, so it alread exists. If you do that, you can use the  
helper image\_tag to have Rails automatically generate the correct tag.  
For example, to display your details.gif, you can do the following :  
\<%= image\_tag "details.gif" %\>  
And Rails will generate the correct img tag (including when the root of  
your Rails application is not the root of your web server), something  
like:  
\<img src="/approot/images/details.gif" alt="DETAILS" /\>

See  
[http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html#M000365](http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html#M000365)  
for more details.
