custom url's and routing

I'm working on a Rails 2.0 app... we're getting read to use AdWords to
drive some traffic... we plan to use a custom URL per ad (to allow us
to track conversions on Google Analytics). The site is an ecommerce
site. The plan is to route the adds to the same today page (and then
track through to conversion or not).

So I'd like ad-1 to use the URL www.foobar.com/ad1, ad-2 to use
www.foobar.com/ad2, and so on. Where all the /adX url's point to
www.foobar.com which is the welcome page.

I know that routes.rb is the way to go but wondering what the elegant
solution is here :slight_smile:

thanks!

I'm working on a Rails 2.0 app... we're getting read to use AdWords to
drive some traffic... we plan to use a custom URL per ad (to allow us
to track conversions on Google Analytics). The site is an ecommerce
site. The plan is to route the adds to the same today page (and then
track through to conversion or not).

So I'd like ad-1 to use the URL www.foobar.com/ad1, ad-2 to use
www.foobar.com/ad2, and so on. Where all the /adX url's point to
www.foobar.com which is the welcome page.

I know that routes.rb is the way to go but wondering what the elegant
solution is here :slight_smile:

map.ad /:ad/, :requirements => {:ad => /ad\d+/}

Put that just above the default route.

If it were me, I'd do it this way just to isolate everything under 'ad':

/ad/1
/ad/2
/ad/3

with a route of:

map.ad /ad/:id, :controller => 'home', :action => 'index'

(assuming home and index are correct for your home page)

-philip

Thanks Philip,

I think the line above has a slight typo in it... the following worked
for...

map.ad '/ad/:id', :controller => 'home', :action => 'index'