Hi !
2006/10/31, Sharkie Landshark
<rails-mailing-list@andreas-s.net>:> 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 !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---