Routes and urls: www.example.com

I'm building an application that stores links, but i've run into a problem with routing. If my routes.rb looks like this:

  map.widget '/widget/show/:url', :controller => "widget", :action => "show"

then when i go to /widget/show/www.example.com then i get an error. If i change the route to:

  map.widget '/widget/show', :controller => "widget", :action => "show"

and i enter in /widget/show?url=www.example.com then everything works great, but i'm currious if there is anything i can do to make the first routing method work?

You might want to try:

map.widget '/widget/show/*url', :controller => 'widget', :action => 'show'

and see if that works. I seem to recall that the dots are the issue, as the router typically uses them to separate formats from request params.

--Matt Jones

That Worked!! Now it looks even better than it did before, I can go to /widget/show/www.example.com without that nasty ?url= . Good Work!! I also have to admit that i should have RTFM Rails Routing from the Outside In — Ruby on Rails Guides mentions this technique, apparently its called Route Globbing and not found until a few minutes of reading. Thanks again for your help Matt!!