Image routing fails on render :update with partial

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 127.0.0.1 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}):
.//vendor/rails/actionpack/lib/action_controller/routing.rb:
1292:in recognize_path' .//vendor/rails/actionpack/lib/action_controller/routing.rb: 1282:inrecognize’

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?

Adam

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:
doesn’t work
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
Javascript.

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

Simon

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.

Adam