How to pin down location of views/shared directory?

My app has a header & footer I want common to each section.
They live in app/views/shared/_header.rhtml & _footer.rhtml.
They are referenced by app/views/layouts/application.rhtml as one would
expect:

<%= render :partial => 'shared/header' %>

They contain many lines like this:
Vehicles

This works great from my app’s root index page. When one navigates to a
controller, e.g. myapp/classifieds/categories, the images can’t be
found. Console shows errors like this:

ActionController::RoutingError (no route found to match
“/classifieds/categories/images/vehiclesButton.jpg” with
{:method=>:get}):

Yet my app seems to find its stylesheets (in public/stylesheets) just
fine. How do I get Rails to find its images in public/images all the
time?

And on a related note I somehow suspect that there’s some kind of url_to
syntax I should be using instead of a naked but it’s not coming
to me.

Thank you.

TC

On Nov 22, 2007, at 4:23 PM, Tom C. wrote:

<img

Yet my app seems to find its stylesheets (in public/stylesheets) just
fine. How do I get Rails to find its images in public/images all the
time?

And on a related note I somehow suspect that there’s some kind of
url_to
syntax I should be using instead of a naked
but it’s not
coming
to me.

Have a look at this article & sample code:
http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/

– gw (www.railsdev.ws)

It turns out that the answer, supplied by EngineYard’s awesome
support, was that I just needed to reference the directory as ‘/
images’ instead of ‘images’.

Thanks for the fine article, Greg, That is one ambitious piece of work!

for images you should use <%= image_tag(‘vehiclesButton.jpg’) %> if
your image is in images directory and it will automagically match the
url where ever you are in your app. If you use something like then it will have some path related problem at
some point of time.

if you want to make your image a link then you can either use link_to
image helper or simply <%=
link_to(image_tag(‘vehiclesButton.jpg’), :controller
=> :controller_name, :action => :action_name) %>

hope this helps

On Nov 23, 12:23 am, Tom C. [email protected]

Excellent, nas, thank you. Just the kind of info I was looking for.