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:
<div id="header">
<%= render :partial => ''shared/header'' %>
</div>
They contain many lines like this:
<a href="/classifies/categories/vehicles"><img
src="images/vehiclesButton.jpg" alt="Vehicles"
class="rollover" /></a>
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 <a href> but it''s not
coming
to me.
Thank you.
TC
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Greg Willits
2007-Nov-23 03:38 UTC
Re: How to pin down location of views/shared directory ?
On Nov 22, 2007, at 4:23 PM, Tom Campbell wrote:> 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: > <div id="header"> > <%= render :partial => ''shared/header'' %> > </div> > > They contain many lines like this: > <a href="/classifies/categories/vehicles"><img > src="images/vehiclesButton.jpg" alt="Vehicles" class="rollover" /></a> > > 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 <a href> 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) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Campbell
2007-Nov-25 04:50 UTC
Re: How to pin down location of views/shared directory ?
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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 <img
src=''someimage.jpg''> 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 Campbell
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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:
> <div id="header">
> <%= render :partial => ''shared/header'' %>
> </div>
>
> They contain many lines like this:
> <a href="/classifies/categories/vehicles"><img
> src="images/vehiclesButton.jpg" alt="Vehicles"
class="rollover" /></a>
>
> 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 <a href> but
it''s not coming
> to me.
>
> Thank you.
>
> TC
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Tom Campbell
2007-Nov-25 21:28 UTC
Re: How to pin down location of views/shared directory ?
Excellent, nas, thank you. Just the kind of info I was looking for. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---