Skip to content

Commit

Permalink
Merge pull request ruby-grape#194 from ppadron/add_docs_for_url_param…
Browse files Browse the repository at this point in the history
…_requirements

Documenting the :requirements option for named route parameters
  • Loading branch information
dblock committed Jun 30, 2012
2 parents 60ea6ca + b5bf0ae commit eb1055e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb1055e

Please sign in to comment.