routes and param oddity

0 views
Skip to first unread message

Ming

unread,
Nov 6, 2009, 1:17:14 PM11/6/09
to merb
I have a route that looks like this

/countries/:ctry(/cities/:city/)(/page/:pg)

if i generate a url that looks like this

/countries/spain/cities/barcelona?page=2


param[:ctry] holds "spain"
param[:city] holds "barcelona"

param[:pg] holds nil
param[page] holds "2"

I expected

param[:pg] holds "2"

but that is not the case.

I am misunderstanding something?

TIA

Chris

unread,
Nov 6, 2009, 8:46:04 PM11/6/09
to me...@googlegroups.com
That's because you're passing page as a query string parameter instead of in the url itself.

Try /countries/spain/cities/barcelona/page/2

which would fit your defined route. Query string params don't have to be declared in the route, anyway.

2009/11/6 Ming <min...@gmail.com>
Reply all
Reply to author
Forward
0 new messages