Conditional routes

Hi !

if CONDITION   map.connect '', :controller => 'stories' else   map.connect '', :controller => 'others' end

routes.rb will be evaluated only once in production. So, your condition will not be processed as you intend.

Instead, you need to have a single action that will either redirect / render the expected layout. Something like this:

# routes.rb map.connect '', :controller => 'take_a_decision', :action => 'choose' map.stories 'stories/:action/:id', :controller => 'stories' map.others 'others/:action/:id', :controller => 'others'

# take_a_decision.rb class TakeADecision < ApplicationController   def choose     if CONDITION       redirect_to(stories_url)     else       redirect_to(others_url)     end   end end

Alternatively: class TakeADecision < ApplicationController   def choose     if CONDITION       render(:action => 'stories')     else       render(:action => 'others')     end   end end

Hope that helps !