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'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With