Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating "Describing and Inspecting an API" to reflect actual behavior #195

Merged
merged 3 commits into from Jul 3, 2012
Merged

Conversation

ppadron
Copy link
Contributor

@ppadron ppadron commented Jul 3, 2012

In the current example, parameters are listed with an array instead of hash:

get "split/:string", { :params => [ "token" ], :optional_params => [ "limit" ] } do

However, it throws the following error: TypeError: can't convert Array into Hash

I have updated the example to use hashes and added a sample helper that performs parameter checking based on the provided information.

helpers do
def validate_request!
# skip validation if no parameter is declared
if route.route_params.nil?; return end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe unwrap this line?

return unless route.route_params

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, that's much better.

@dblock
Copy link
Member

dblock commented Jul 3, 2012

Merging, thank you for the update.

dblock added a commit that referenced this pull request Jul 3, 2012
Updating "Describing and Inspecting an API" to reflect actual behavior
@dblock dblock merged commit 575e6fc into ruby-grape:master Jul 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants