# Img in layout disappears when controller renders view

**URL:** <https://www.ruby-forum.com/t/img-in-layout-disappears-when-controller-renders-view/123823>\
**Category:** Rails\
**Created:** [December 20, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/img-in-layout-disappears-when-controller-renders-view/123823 "2007-12-20T23:12:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [December 20, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/img-in-layout-disappears-when-controller-renders-view/123823/1 "2007-12-20T23:12:20Z")

</div>

I have a application level layout and no other layouts. The layout  
consists of a static image wrapped in a div tag and my controllers  
render scaffold generated views into the “yield” statement after the  
header div.

My header image is located in the “public/images” folder. When the  
“index” view of any of my controllers is rendered, everything works  
great. When I click any of the scaffold generated links (new, edit,  
show) within the “index” page, the corresponding view is rendered in the  
layout same as before, however the header image does not display. When  
viewing the console log, the log shows a 404 error to “GET  
/controller\_name/images/header.gif”. What’s going on here? Why is the  
path for the image in the layout changing based on the controller? If I  
click the edit button, which passes the record number as a parameter to  
the controller’s edit method the path again gets appended (GET  
/controller\_name/1/images/header.gif).

Is this a routing issue or something I haven’t setup correctly?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [December 20, 2007, 11:40pm UTC](https://www.ruby-forum.com/t/img-in-layout-disappears-when-controller-renders-view/123823/2 "2007-12-20T23:40:04Z")

</div>

Because you’re referencing the image as ![]()

Use \<%= image\_tag(“header.gif”) %\> instead.

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [December 20, 2007, 11:57pm UTC](https://www.ruby-forum.com/t/img-in-layout-disappears-when-controller-renders-view/123823/3 "2007-12-20T23:57:00Z")

</div>

Ryan B. wrote:

> Because you’re referencing the image as ![]()
> 
> Use \<%= image\_tag(“header.gif”) %\> instead.

I feel dumb. Thanks. That worked great. Still learning as I go here.

Thanks again,
