-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
📝 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
Conversation
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dblock done!
Merged, thank you. |
Context
As of 1.6+ Grape only allows you to use
declared(params)
when usingas
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.