Rails 2.3.x equivalent of Rails3 optional route parameters

routes, ruby-on-rails

Solution

A parameter becomes optional if you specify a default value.

map.page '/page/:section', :action => 'page', :section => "default"

If `:section` is present, the value will be the current value. Otherwise, it will default to `default` and the router won't complain.

You can also default the value to `nil`.

map.page '/page/:section', :action => 'page', :section => nil

Problem

In Rails 3 I can do something like this: ``` match "/page(/:section)", :to => 'some_controller#page' ``` And both `/page` and `/page/some_section` will map to some_controller#page Is there an equivalent of this in Rails 2.3.x ?? I can't seem to find it I'm currently using two separate route methods like so: ``` map.page '/page', :action => 'page' map.page_section '/page/:section', :action => 'page' ```

Original source