-
Notifications
You must be signed in to change notification settings - Fork 61
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
Refactor ActiveModel::ErrorSerializer #98
Conversation
2e64896
to
f0b9dbd
Compare
Test Ruby 3.3 and Rails 6.1 instead
The previous specs were harder to read, and they relied on the ordering of the errors, which is unnecessary.
We're only running CI for Rails 6.1+ now, and we can now rely on a stable API for ActiveModel::Errors.
f0b9dbd
to
89f6e61
Compare
end | ||
|
||
attribute :source do |object, params| | ||
error_key, _ = object | ||
error_key = object.attribute |
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 seems before this change an array was supported here as object
but now it is not. Is there a reason for the change in behavior there?
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.
No, that was certainly not intended, but there was also no test for it. If you depend on that behaviour, as a spec and an Array.wrap
or similar as a PR.
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.
if this is more correct i can update on my end. we were building up these errors manually (for some unknown reason) which this suddenly broke.
I'm not the maintainer, just did this particular refactoring. So that
decision would be on you and @stas.
Aaron Roberts ***@***.***> schrieb am Mo., 15. Juli 2024,
19:26:
… ***@***.**** commented on this pull request.
------------------------------
In lib/jsonapi/active_model_error_serializer.rb
<#98 (comment)>:
> end
attribute :source do |object, params|
- error_key, _ = object
+ error_key = object.attribute
if this is more correct i can update on my end. we were building up these
errors manually (for some unknown reason) which this suddenly broke.
—
Reply to this email directly, view it on GitHub
<#98 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFLXKJTQNT4EJVGWFJCK4TZMPIHJAVCNFSM6AAAAABJYJ4CW2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNZXG44TGNJSGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
What is the current behavior?
No behavior change, but the ActiveModel::ErrorSerializer reads much nicer.
Checklist
Please make sure the following requirements are complete:
features)