Skip to content

Commit 21e5b78

Browse files
author
Pedro Padron
committed
parameters must be specified with a Hash instead of an Array
1 parent eb1055e commit 21e5b78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,13 @@ Parameters can also be tagged to the method declaration itself.
650650

651651
``` ruby
652652
class StringAPI < Grape::API
653-
get "split/:string", { :params => [ "token" ], :optional_params => [ "limit" ] } do
653+
get "split/:string", { :params => { "token" => "a token" }, :optional_params => { "limit" => "the limit" } } do
654654
params[:string].split(params[:token], (params[:limit] || 0))
655655
end
656656
end
657657

658-
StringAPI::routes[0].route_params # yields an array [ "string", "token" ]
659-
StringAPI::routes[0].route_optional_params # yields an array [ "limit" ]
658+
StringAPI::routes[0].route_params # yields a hash {"string" => "", "token" => "a token"}
659+
StringAPI::routes[0].route_optional_params # yields a hash {"limit" => "the limit"}
660660
```
661661

662662
It's possible to retrieve the information about the current route from within an API call with `route`.

0 commit comments

Comments
 (0)