Routing to arbitrary deeply nested resources

I’ve got a tree of nodes to which I want to route requests. Currently
I’m using simple resource routing:

map.resources :nodes

Rather than a flat URLspace where all nodes are access via:

/nodes/id

I’d prefer an arbitrary deeply nested URLspace:

/nodes/id
/nodes/id/child
/nodes/id/child/grandchild

Both to make inserting new nodes simpler, and to make context-specific
searching easier.

Can anyone suggest how I might approach this problem?

  • donald

Ball, Donald A Jr (Library) wrote:

/nodes/id
/nodes/id/child
/nodes/id/child/grandchild

Both to make inserting new nodes simpler, and to make context-specific
searching easier.

Can anyone suggest how I might approach this problem?

  • donald

Use * and write your own routing method? E.g.:

map.connect ‘nodes/*rparams’,
:controller => “nodes”,
:action => “router”

and rparams will be passed into router as an array of values.

–
Michael W.

I’d prefer an arbitrary deeply nested URLspace:

  • donald

Use * and write your own routing method? E.g.:

map.connect ‘nodes/*rparams’,
:controller => “nodes”,
:action => “router”

and rparams will be passed into router as an array of values.

That’s a thought, thanks for the suggestion. Sadly, it means I can’t use
any of the nice url generator methods provided by rails routing, but
it’d work. I’ll give it a whirl.

  • donald