# How to pin down location of views/shared directory?

**URL:** <https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038>\
**Category:** Rails\
**Created:** [November 23, 2007, 1:23am UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038 "2007-11-23T01:23:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [November 23, 2007, 1:23am UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038/1 "2007-11-23T01:23:26Z")

</div>

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]()](https://www.ruby-forum.com/classifies/categories/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

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [November 23, 2007, 4:41am UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038/2 "2007-11-23T04:41:45Z")

</div>

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

> [\<img](https://www.ruby-forum.com/classifies/categories/vehicles)
> 
> [ 
> 
> 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?
> 
> ](https://www.ruby-forum.com/classifies/categories/vehicles)
> 
> [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 ](https://www.ruby-forum.com/classifies/categories/vehicles) 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/](http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/)

– gw (www.railsdev.ws)

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [November 25, 2007, 5:51am UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038/3 "2007-11-25T05:51:17Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [November 25, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038/4 "2007-11-25T12:19:19Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [November 25, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/how-to-pin-down-location-of-views-shared-directory/121038/5 "2007-11-25T22:28:35Z")

</div>

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