- Notifications
You must be signed in to change notification settings - Fork22.1k
Use public_send in value_for_collection#33547
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rails-bot commentedAug 7, 2018
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from@georgeclaghorn (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues usingCode Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please seethe contribution instructions for more information. |
Avoid exposing private methods in view's helpers.Fixesrails#33546
matthewd commentedAug 7, 2018
Hi! I agree we should change this. (And the other If it's worth fixing, it's worth keeping fixed, so we should add a test too. My big question-mark, however, is whether we need a deprecation. Much as |
rafaelfranca commentedAug 7, 2018
Agree. It is safer if we deprecate it. |
Ana06 commentedAug 8, 2018
👍
I'll add it 😉 @matthewd@rafaelfranca regarding the deprecation, I guess you mean showing a message in case that the method used is private and not to deprecate the method itself, right? |
matthewd commentedAug 8, 2018
Right. I think we'd do it something like this: beginitem.public_send(value)rescueNoMethodErrorifitem.respond_to?(value,true) && !item.respond_to?(value)ActiveSupport::Deprecation"Hey don't do that"item.send(value)elseraiseendend |
Avoid exposing private methods in view's helpers. However, as`extract_values_from_collection` is only called from`options_from_collection_for_select` where `value_for_collection` ispreviously called, this case was already covered. The change makesanyway sense for consistency and in case the code changes in thefuture.
1fb8b26 toca77aabCompareAna06 commentedAug 8, 2018
I think at least0c62e14 should be rebased into87b6e6a, but I left it like that following@rails-bot instructions:
|
Instead of dropping it completely in case someone is relying (probablyinadvertenly) on it.
6adcd14 todef801aCompareTest that using private methods in `options_from_collection_for_select`is deprecated.Make the unused `secret` paramether in the `Post` Struct private to useit in the test.
Ana06 commentedAug 8, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@matthewd@rafaelfranca I think the changes are addressed, please take a look. 🙏 Do we need to test other view's helpers or is it enough with testing |
georgeclaghorn commentedAug 10, 2018
Ana06 commentedAug 21, 2018
@matthewd something else to change? 🤔 |
Use public_send in value_for_collection
matthewd commentedAug 22, 2018
Nope, this is great, thanks! ❤️ I made a few of tweaks in the merge commit, FYI:047a893 (changelog formatting, and I added the name of the called private method to the deprecation message) |
Ana06 commentedAug 22, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
matthewd commentedAug 22, 2018
@Ana06 all your commits are in there:https://contributors.rubyonrails.org/contributors/ana-maria-martinez-gomez/commits (Oops.. if I'd seen there were so many I should've gotten you to squash. Oh well. 🤷🏻♂️) |
Ana06 commentedAug 22, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
you are right, sorry 🙈 I though you squashed the commits, because they needed to be squashed and I didn't see them in the commits history. It seems it is a different way to merge things (withour rebasing) and I didn't see them 👀 Thanks for merging it 😉 |
matthewd commentedAug 22, 2018
No worries, thanks for the work! (It's an ordinary merge, but that means your commits are further down the list [currently on page 5 by my count], based on their commit date, even though they only just hit master.) |
Ana06 commentedAug 28, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@matthewd@rafaelfranca I spoke about this PR in my talk at EuRuKo (in front of around ~550 people), maybe you want to watch it:https://youtu.be/jUc8InwoA-E?t=2m54s 😉 The part where I speak about this is almost as the end, but I am not sure if it is possible to follow without watching the whole talk. 🤔 It is anyway not that long! only 25 minutes 😄 |
Uh oh!
There was an error while loading.Please reload this page.
Deprecate use of private methods in view's helpers. We should start calling
public_sendinvalue_for_collectioninstead ofsendto void exposing private methods in view's helpers.Fixes#33546