Routing via function

I have a route that depends on a username being passed in the URL, such
as:

map.connect ‘:username’, :controller => ‘user’, :action => ‘show’

Is there a way to perform a lookup of the username before matching on
this route?

I am hoping to be able to do something like this (completely made up):

:requirements => {:username => {|username|
User.find_by_username(username)}}

I vaguely remember seeing a post a few months ago related to this but
I have had no luck digging it up.

Thanks,

Tom D.

http://atomgiant.com
http://gifthat.com

OK, I found the original post for how to do this:
http://www.ruby-forum.com/topic/42505

I was hoping the new rewritten routing in edge rails would have added
this functionality in a less hacky way, but I tried various means of
getting it to work and I don’t think it is directly supported without
overriding the routing.recognition_conditions method.

So, for now I will go the RegEx way.

Tom

On 7/5/06, Tom D. [email protected] wrote:

I vaguely remember seeing a post a few months ago related to this but
I have had no luck digging it up.

Thanks,

Tom D.

http://atomgiant.com
http://gifthat.com


Tom D.

http://atomgiant.com
http://gifthat.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs