From b5bf0aeb7877e6bd6132b905bc68414df7b05343 Mon Sep 17 00:00:00 2001 From: Pedro Padron Date: Sat, 30 Jun 2012 04:27:29 -0300 Subject: [PATCH] adding docs for named route parameters requirements --- README.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.markdown b/README.markdown index 44213c9fa7..5136252908 100644 --- a/README.markdown +++ b/README.markdown @@ -77,6 +77,15 @@ class Twitter::API < Grape::API end ``` +Optionally, you can define requirements for your named route parameters using regular expressions. The route will match only if +all requirements are met. + +```ruby +get '/show/:id', :requirements => { :id => /[0-9]*/ } do + Tweet.find(params[:id]) +end +``` + ## Mounting The above sample creates a Rack application that can be run from a rackup *config.ru* file