Is there a way in the Ruby On Rails Routing framework to make a decision about which controller or action to call based on some logic all within a single route?
For example, let's say have a url zip/354
and I want to call the foo
action if the integer is even and the bar
action if the integer is odd. To use pseudo-ruby:
map.connect 'zip/:id', :requirements=>{:id=>/^\d+$/} do |id|
:controller=>'c', :action=>'foo' if id.to_i % 2 == 0
:controller=>'c', :action=>'bar' if id.to_i % 2 != 0
end