Problem Locating image resources - JRuby on Rails

Hi,

I’m having a problem with a rails app deployed on Tomcat where the
server cannot locate images.

When I hit the url ‘http://localhost:8080/myapp/public/index
everything is fine.

However, the Rails generated link to this url drops the ‘index’
action, resulting in ‘http://localhost:8080/myapp/public’. The page
generated by this truncated url results in image tags that can’t be
resolved by tomcat. This only occurs in Tomcat, not Mongrel so I
imagine the problem resides in my web.xml configuration.

My View contains code like this:

<%= image_tag(“header.jpg”, :size => ‘418x117’, :align => “left”)%>

which resolves to an img element like:

Header

This is the exact same img element that gets generated when I hit the
http://localhost:8080/myapp/public/index’ URL.

Has anyone experienced this problem? I was hoping I to supply some
sort of parameter to the web.xml file to resolve this, but I haven’t
found anything exclude url’s aren’t possible).

Environment:
-I’m using tomcat 5.5.9
-I’m using Rails 1.2.3
-I’m using warble 0.9.5 to create the war.

Warbler modifies the default layout of a rails app (putting the app
dir under WEB-INF and resources (images, stylesheets, etc) in the
parent dir. However, the fact that Image urls are generated properly
for all other requests makes me think the problem resides elsewhere.

Thanks.


Caleb

“I do not know which makes a man more conservative—to know nothing but
the present, or nothing but the past.”

  • John Maynard Keynes

On Wed, May 14, 2008 at 9:47 PM, Caleb P. [email protected]
wrote:

generated by this truncated url results in image tags that can’t be
src=“/myapp/images/header.jpg” width=“418” />

This is the exact same img element that gets generated when I hit the
http://localhost:8080/myapp/public/index’ URL.

Has anyone experienced this problem? I was hoping I to supply some
sort of parameter to the web.xml file to resolve this, but I haven’t
found anything exclude url’s aren’t possible).

How does the “public” part of the URI figure in? Where does your image
reside in the war file?

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

How does the “public” part of the URI figure in? Where does your image
reside in the war file?

There is nothing special about ‘public’ in the URL. It simply refers
to a public_controller class. I have a corresponding admin_controller
class that is accessed via the http://localhost:8080/myapp/admin
url.
FYI, my routing file looks like:

map.connect ‘public/:action’, :controller => “public”
map.connect ‘admin/:controller/:action/:id’
map.connect ‘’, :controller => “public”
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
map.connect ‘*anything’, :controller => ‘public’, :action =>
‘resource_not_found’

The image is inside the rails default images directory. So it looks
like:

-myapp/
-WEB-INF/
-images/header.jpg
-stylesheets/
-javascripts/

I will try another app to see if I can reproduce the problem.

Caleb

“I do not know which makes a man more conservative—to know nothing but
the present, or nothing but the past.”

  • John Maynard Keynes

I tried this in another - very simple - rails app and the problem
still occurs. So it has nothing to do with routing.

For clarification, the image that won’t display is in the layout view
for the controller. The other images in the views display.


Caleb

“I do not know which makes a man more conservative—to know nothing but
the present, or nothing but the past.”

  • John Maynard Keynes