Skip to content
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

Merged
merged 4 commits into from
Jun 23, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jan 31, 2024

What is the current behavior?

No behavior change, but the ActiveModel::ErrorSerializer reads much nicer.

Checklist

Please make sure the following requirements are complete:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes /
    features)
  • All automated checks pass (CI/CD)

@mamhoff mamhoff force-pushed the pretty-activemodel-errors branch from 2e64896 to f0b9dbd Compare January 31, 2024 17:53
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.
@mamhoff mamhoff force-pushed the pretty-activemodel-errors branch from f0b9dbd to 89f6e61 Compare February 1, 2024 08:32
@stas stas merged commit 52b4128 into stas:master Jun 23, 2024
12 checks passed
end

attribute :source do |object, params|
error_key, _ = object
error_key = object.attribute

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?

Copy link
Contributor Author

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.

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.

@mamhoff
Copy link
Contributor Author

mamhoff commented Jul 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants