Skip to content

Instantly share code, notes, and snippets.

@paul
Created October 24, 2008 16:55
Show Gist options
  • Save paul/19488 to your computer and use it in GitHub Desktop.
Save paul/19488 to your computer and use it in GitHub Desktop.
Merb::Router.prepare do
# match('/templates/:template_id', :template_id => /.+/) do
# match('/questions/:name').to(:controller => 'questions', :action => 'show').name(:question)
# match('/questions').to(:controller => 'questions', :action => 'index').name(:questions)
# end
# match('/templates').to(:controller => 'templates', :action => 'index').name(:templates)
# match('/templates/:id', :id => /.+/).to(:controller => 'templates', :action => 'show').name(:template)
resources :templates, :id => /.+(?=(/questions)?/ do
resources :questions, :keys => :name, :name => /.+/
end
end
# I need to match paths like:
#
# /templates/foo/bar {:controller => 'templates', :id => 'foo/bar'}
# /templates/foo/bar/questions {:controller => 'questions', :template_id => 'foo/bar'}
# The commented-out routes match ok, but the #resources for does not,
# using both :id => /.+/ and the lookahead I have in there now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment