Forum: Ruby on Rails Route for any image?

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.
David C. (Guest)
on 2006-03-15 22:12
(Received via mailing list)
I want to create a route for any image.  This is in order to create an
report explaining what the missing image is.  I could create a route for
each directory that currently has images in it but wanted something more
general like:

  map.connect "/**/*.gif", :controller => 'image_handler', :action =>

Which doesn't work.   Anyone know more about the inner workings?

Daniel W. (Guest)
on 2006-03-15 22:30
(Received via mailing list)
You can only use * once. It catches everything and stores it into a
variable of your choosing. (e.g. map.connect '*path' will give you the
contents of the URL in params[:path])


map.connect 'some/*path', :controller => 'pages', :action =>

But... I don't think routes are the best way to achieve your goal, if
your goal is to scan your site for broken images. (What WOULD be a
good way I dunno...) (I doubt you can even do what you want with

- Rabbit

Doug Fales (Guest)
on 2006-03-15 23:10
(Received via mailing list)
Here's one way:

In your config/routes.rb file:
  map.connect  "*anything", :controller => "unknown", :action =>

In your app/controllers/unknown_controller.rb file:

   # Unknown URLs get routed to this action.
   def unknown_url
      missing_image =

      if missing_image
         img_name = missing_image[1]
         logger.error("Request for nonexistent image #{img_name} at
URI #{@request.request_uri}...")
         # Send your email here...


This topic is locked and can not be replied to.