Img in layout disappears when controller renders view

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.

Because you’re referencing the image as

Use <%= image_tag(“header.gif”) %> instead.

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,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs