Remove Deprecation Warning in ActiveModel Errors#3946
Merged
kennyadsl merged 1 commit intosolidusio:masterfrom Feb 23, 2021
Merged
Remove Deprecation Warning in ActiveModel Errors#3946kennyadsl merged 1 commit intosolidusio:masterfrom
kennyadsl merged 1 commit intosolidusio:masterfrom
Conversation
houndci-bot
reviewed
Feb 19, 2021
aldesantis
requested changes
Feb 19, 2021
Member
aldesantis
left a comment
There was a problem hiding this comment.
@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
kennyadsl
reviewed
Feb 20, 2021
Member
kennyadsl
left a comment
There was a problem hiding this comment.
Thanks, I left an improvement for checking the Rails version requirement.
8409b90 to
dc5c975
Compare
Member
|
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
Contributor
Author
|
@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. |
aldesantis
approved these changes
Feb 23, 2021
Member
aldesantis
left a comment
There was a problem hiding this comment.
Awesome stuff, thanks @Azeem838!
Member
|
I backported this to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is a solution for #3924
Enumerating ActiveModel::Errors as a hash has been deprecated. In Rails 6.1,
errorsis 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: