Forum: Ruby on Rails Image routing fails on render :update with partial

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Adam T. (Guest)
on 2007-02-07 04:20
(Received via mailing list)
Hey, gang.

I just ran into this problem today, possibly because I've added named
routes into the mix in my application, or because of some other change
I'm unaware of. Either way, it's completely puzzling.

I have a page that updates (renders) a partial when a form is
submitted on the same page. The partial contains a few images. On the
first run through the page (a fresh reload), the page renders
correctly, there are no exceptions in the logs, and everything seems
fine. When I submit the form and cause the render :update to occur,
however, I get a RoutingError exception to the following tune:

Processing ApplicationController#index (for at 2007-02-06
18:12:00) [GET]
  Session ID: sdfasdfasfasdf
  Parameters: {"1160418884\\\\\\\""=>nil}

ActionController::RoutingError (no route found to match "/contacts/
show/\\\\\\\"/images/world.png" with {:method=>:get}):
1292:in `recognize_path'
1282:in `recognize'

What's more puzzling is that it actually raises TWO exceptions, one
for "/contacts/show/\\\\\\\"/images/world.png" and one for "/contacts/
show/\\\"/images/world.png." It's strange enough to see these errors
occur, but what's even stranger is that my server is actually still
serving the images!

I'm running this in dev mode, so my server is Mongrel, although I'm
not really sure that matters. Has anyone run into this problem before?

simonp (Guest)
on 2007-02-07 09:52
(Received via mailing list)
Hello Adam,

I ran into the same problem a few days ago when I switched my
application from 1.1.6 to 1.2.

I discovered that using plain-old html img tags with the src attribute
value surrounded by single quotes fixed the issue:
<img src="/images/world.png" /> doesn't work
<img src='/images/world.png' /> works

Could you give it a try and tell us if it works for you? I'm not sure
but it may be due to "improper" character escaping in the rendered

As a side note, I think that your browser displays the images
correctly because they are in the cache after the first page load.

Adam T. (Guest)
on 2007-02-07 21:35
(Received via mailing list)
Thanks for the response, Simon.

That actually worked somewhat, but it only fixed one of the
exceptions. One exception still came through as "no route found to
match "/contacts/show/\\'/images/company.png\\'" with
{:method=>:get})." I'm assuming the exception is getting thrown
because the "catch" code in the JavaScript return is still getting
interpretted, if not called.

This topic is locked and can not be replied to.