views:

751

answers:

1

Hi,

I'm using a configuration file to route my requests in my application. I have the following entries:

routes.deal.route = "deal/:id/*"

routes.deal.defaults.controller = "deal"

routes.deal.defaults.action = "index"

routes.deal.reqs.id = "\d+"

routes.deal.route = "deal/buy/:id/*"

routes.deal.defaults.controller = "deal"

routes.deal.defaults.action = "buy"

routes.deal.reqs.id = "\d+"

here's what the behavior I'm looking for: mysite.com/deal/75 --- this will display the details of Deal 75 (equivalent to mysite.com/deal/?id=75; controller=deal, action=index)

mysite.com/deal/buy/75 -- buy deal 75 or (controller=deal, action=buy) -- equivalent to mysite.com/deal/buy?id=75

I can only get one to work and not the other. Whichever is specified first in the config, that's what will work.

Can anyone point out what I'm doing wrong here? Any help is greatly appreciated.

thanks, Oji

A: 

Try changing the name of the second route, i.e:

routes.dealbuy.route = "deal/buy/:id/*"
routes.dealbuy.defaults.controller = "deal"
routes.dealbuy.defaults.action = "buy"
routes.dealbuy.reqs.id = "\d+"

The routes need to have different names.

Mads Mobæk
thanks mobmad! Works perfectly.
Great to hear! I see you are new to Stack Overflow. If this solution works for you, it's common practise to mark this solution as accepted by clicking the checkmark next to my answer. You can also vote answers up by clicking the up-arrow next to the question. Thanks.
Mads Mobæk
I tried clicking on the Up button but the number doesn't seem to change. It keeps saying "Vote up requires 15 reputation"
Yes, that's correct. Although you should still be able to mark it as accepted. See http://meta.stackoverflow.com/questions/5234/accepting-answers-what-is-it-all-about for more info
Mads Mobæk