Route with optional segments

In Rails 2.3.5, is this the proper way to do this?

map.calls “calls/:group/:view/:subselect”, :controller => ‘calls’,
:action => ‘index’
map.calls “calls/:group/:view”, :controller => ‘calls’,
:action => ‘index’
map.calls “calls/:group”, :controller => ‘calls’,
:action => ‘index’
map.calls “calls”, :controller => ‘calls’,
:action => ‘index’

I want to accept

/calls
/calls/abc
/calls/abc/def
/calls/abc/def/ghi

where “group” would be assigned “abc” in cases 2-4, “view” would be
assigned “def” in cases 3 and 4, and subselect would be assigned “ghi”
in case 4.

I kept trying to do something like:

/calls(/%group(/%view(/%subselect)?)?)?

but never got it to work.

Thank you,
pedz

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs