-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove Deprecation Warning in ActiveModel Errors #3946
Remove Deprecation Warning in ActiveModel Errors #3946
Conversation
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.
@Azeem838 thanks for the work here!
In order to make the code work with Rails 5.2 and 6.0 as well, you can simply check the current Rails version in an if/else
branch.
b57fc98
to
b4e9333
Compare
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.
Thanks, I left an improvement for checking the Rails version requirement.
8409b90
to
dc5c975
Compare
Thanks! Can you please just squash commits into a single one and we are good to go! 🙏 |
Refactor validation methods from using the shovel operator to use the add method. Refactor validation methods and to accept a single block parameter.
dc5c975
to
b570715
Compare
@aldesantis and @kennyadsl, thank you both for your advice on this PR. Please let me know if there are any other changes that needs to be made. |
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.
Thank you! 🙏
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.
Awesome stuff, thanks @Azeem838!
I backported this to |
Description
This PR is a solution for #3924
Enumerating ActiveModel::Errors as a hash has been deprecated. In Rails 6.1,
errors
is an array of Error objects, therefore it should be accessed by a block with a single block parameter.This resulted in deprecation warnings in the payment and product models for the validate_source and validate_master methods respectively.
Since this is deprecated, it will result in an ArgumentError in Rails 6.2.
Other Deprecation Warning
There were warnings relating to the shovel operator being used in various model validators. As with the previous deprecation warning, the use of the shovel operator within this context has been deprecated. The affected methods were changed to use ruby's add method instead.
This PR takes care of this issue as well
Checklist: