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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D689f1592faf0864644346f08bc70f5c?d=identicon&s=25 Adam Traver (atraver)
on 2007-02-07 03: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 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: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?

Adam
669e19951b848d1b0dac78655e34c2a4?d=identicon&s=25 simonp (Guest)
on 2007-02-07 08: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
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
D689f1592faf0864644346f08bc70f5c?d=identicon&s=25 Adam Traver (atraver)
on 2007-02-07 20: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.

Adam
This topic is locked and can not be replied to.