Forum: Ruby on Rails Another routing question

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.
57a175cd9602613be71bff2912b2b3f8?d=identicon&s=25 Chris Roos (chrisjroos)
on 2005-12-14 13:59
I have a route similar to

map.connect 'images/:action/:image', :controller => 'images',
:requirements => { :image => /^.*\.gif$/ }

The :image should always be a number appended with .gif (I realise the
regex doesn't reflect this currently).  I'd like to extract the numeric
part of the image filename to be used as :id.  I can do this easily
within the controller but wonder if it's even possible within the
routing.

To reduce the problem slightly, I'd basically like to be able to create
a route similar to..

map.connect 'images/:action/:image', :controller => 'images', :alt_image
=> :image

..where :alt_image gets the content of the :image part of the url.

I just did some digging into the routing and notice that map.connect
actually returns me a component.  I was wondering if I could amend this
object, although I don't think that would be great.

Are there any ways currently of achieving what I need or, indeed, any
obvious reasons why I shouldn't even be thinking about it?

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