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

Support Rails 6.1-style errors #3

Open
joshpencheon opened this issue Feb 11, 2021 · 1 comment
Open

Support Rails 6.1-style errors #3

joshpencheon opened this issue Feb 11, 2021 · 1 comment

Comments

@joshpencheon
Copy link
Contributor

Rails 6.1 has changed how errors are structured internally, which will affect how activemodel-caution should function.

See the new API docs.

# On the rails/rails repo:
$ git diff v6.0.3.5..v6.1.2.1 --stat -- {activemodel/lib/active_model,activerecord/lib/active_record}/{error,validat}*
 activemodel/lib/active_model/error.rb                      | 207 +++++++++++++++
 activemodel/lib/active_model/errors.rb                     | 524 +++++++++++++++++++++++---------------
 activemodel/lib/active_model/validations.rb                |  12 +-
 activemodel/lib/active_model/validations/absence.rb        |   2 +-
 activemodel/lib/active_model/validations/acceptance.rb     |   2 +-
 activemodel/lib/active_model/validations/callbacks.rb      |  30 +--
 activemodel/lib/active_model/validations/clusivity.rb      |   6 +-
 activemodel/lib/active_model/validations/confirmation.rb   |   4 +-
 activemodel/lib/active_model/validations/exclusion.rb      |   2 +-
 activemodel/lib/active_model/validations/format.rb         |   4 +-
 activemodel/lib/active_model/validations/inclusion.rb      |   2 +-
 activemodel/lib/active_model/validations/length.rb         |   4 +-
 activemodel/lib/active_model/validations/numericality.rb   |  95 ++++---
 activemodel/lib/active_model/validations/presence.rb       |   2 +-
 activemodel/lib/active_model/validations/validates.rb      |  10 +-
 activemodel/lib/active_model/validator.rb                  |   8 +-
 activerecord/lib/active_record/errors.rb                   |  59 ++++-
 activerecord/lib/active_record/validations.rb              |   1 +
 activerecord/lib/active_record/validations/numericality.rb |  35 +++
 activerecord/lib/active_record/validations/uniqueness.rb   |  28 +-
 20 files changed, 734 insertions(+), 303 deletions(-)

We'll likely need to swap activemodel-caution over to the new structure, as well as mirror the deprecations.

Frustratingly, we've still got a number of use cases for the "active" warnings... regardless, I wonder if it might not be possible to change how this gem functions - to give objects a proxy "warning object" that uses ActiveModel::Error, meaning we'd not be duplicating the entire library.

@joshpencheon
Copy link
Contributor Author

cc: @miles-smith , something to mull on!

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

No branches or pull requests

1 participant