-
Notifications
You must be signed in to change notification settings - Fork 354
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
Fixed Calling << to an ActiveModel::Errors
deprecation warning
#690
Fixed Calling << to an ActiveModel::Errors
deprecation warning
#690
Conversation
This is currently failing linting due to:
Any suggestion on how to resolve that @lcreid ? |
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 for submitting a PR. We should have a test that shows that this is fixed. I believe our test suite wasn't triggering this code before, which is why we never noticed the error. Do you have a test that can reproduce the error (before your fix) that we could add to our tests?
I wonder why that's come up for you? Perhaps that's why the original code used a temporary variable? For now, put |
@lcreid ive added a test case which triggers the warning when you change |
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.
This looks great. I'm interested in seeing your response to my comments before approving, but we should be good to go after that.
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.
Do we need the AddressesController
and the routes for addresses?
object.class.try(:reflections)&.each do |association_name, a| | ||
next unless a.is_a?(ActiveRecord::Reflection::BelongsToReflection) | ||
next unless a.foreign_key == name.to_s | ||
|
||
messages << object.errors[association_name] | ||
object.errors[association_name].each do |error| | ||
object.errors.add(name, error) |
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 was intrigued by your comment that it didn't say anything at version 7. You would think it should have errored, if the deprecation warning was in 6.1. You're right. <<
seems to still work, and without a deprecation message. Very strange.
I was unable to get it to show me the deprecation message, even with version 6.1. (I tweaked the code to run your test case, but with the <<
operator instead of #add
.) Also strange. At any time, did you see the deprecation warning when running the test you added?
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.
Oops. Looks like the test fails on edge. |
It looks like it doesn't pick up that the relationship is required in rails 7.1. Possibly something in |
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 for removing the unnecessary code.
We can merge this with failing tests in edge. I've created an issue for that failure. The issue has a lead about what may be the problem.
Fixes #689