Skip to content

📝 Update README.md with rename-ing notes for params #2259

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

Merged
merged 3 commits into from
Jun 6, 2022

Conversation

danielvdao
Copy link
Contributor

@danielvdao danielvdao commented Jun 1, 2022

Context

As of 1.6+ Grape only allows you to use declared(params) when using as parameter for renaming parameters.

It's referenced in an issue: #2237 and also referenced here.

Was confused for a bit until I found the issue - so thought it could help save some future folks (e.g. me!) time. Decided to remove the legacy way of accessing renamed parameters and suggest only using declared(params) moving forward.

README.md Outdated
@@ -1450,6 +1450,8 @@ end

The value passed to `as` will be the key when calling `params` or `declared(params)`.

Note: If you are on 1.6+, then you'll need to use `declared(params)` to access your renamed parameter. See [inspiration here](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md#upgrading-to--160) as to why.
Copy link
Member

Choose a reason for hiding this comment

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

I understand that you ran into a problem upgrading, but we generally don't put version-specific information in README like this. Is there anything that can be added to the text that isn't and is helpful at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't a problem upgrading as we already started out > 1.6. It was that when I read the docs I read it as either params or declared(params) would get me the renamed parameter.

The former isn't true and it took me a couple of hours of debugging until I found #2237 and noticed that we were 1.6+ 😓

Is there anything that can be added to the text that isn't and is helpful at the same time?

"Note: It's preferable to use declared(params) to access renamed parameters as using params to access renamed parameters can lead to unexpected parameter behavior."

(Trying to be broad but not too much emphasis on the 1.6 upgrade like you mentioned.)

Curious what other ways to rephrase you have in mind? Ideally it's a note that's helpful like you said 🤔

Copy link
Member

@dblock dblock Jun 5, 2022

Choose a reason for hiding this comment

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

Ok, so if the former isn't true anymore, remove it, it should have been removed then! The README is for the latest (specific/current) version only and should not document anything that doesn't work in the matching codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dblock done!

@danielvdao danielvdao requested a review from dblock June 2, 2022 19:39
@dblock dblock merged commit 5cc3226 into ruby-grape:master Jun 6, 2022
@dblock
Copy link
Member

dblock commented Jun 6, 2022

Merged, thank you.

@danielvdao danielvdao deleted the patch-1 branch June 6, 2022 23:13
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.

2 participants