My application cannot download images from the server

I use Ruby on Rails on my local WEBrick server.

I generate some website images from URLs, write them to my local file system and display them. I name the images by their URL, but replace everything \with -. Some images do not seem to load because they cannot find the images in my file system and I get a broken image icon. However, I see that all the images are there when I check my file system.

This is the error I get in my logs:

Started GET "/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379" for 127.0.0.1 at Thu Jun 30 13:23:06 -0700 2011

ActionController::RoutingError (No route matches "/images/image_site/http:--www.urbandictionary.com-define.php"):

This is my html code:

<img alt="Http:--www.urbandictionary.com-define.php?term=slim%20shady" class="site_image" src="/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379">

What is happening and how can I fix it? Please let me know if I need to provide more information.

0
source share
2 answers

It looks like you are incorrectly encoding the image names in the attribute src. I assume you have a file with this name:

http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg

But when you have this:

src="/images/image_site/http:--www.urbandictionary.com-define.php?term=slim%20shady.jpg?1309465379"

The file name is as follows:

/images/image_site/http:--www.urbandictionary.com-define.php

because everything after the first ?is considered part of the query string.

, . , id.jpg, id - . ( !) , .

URL- src. , , .

+3

public/, . Rails public/.

-1

All Articles