grape
grape copied to clipboard
handle the changes in errors method in rails 6.1
solve #2168
as active_record_instance#errors metho is not returning a hash object anymore. as a part of rails 6.1 upgrade
the JSON error formatter should consider this change and check if the object type is ActiveModel::DeprecationHandlingMessageHash
| 2 Warnings | |
|---|---|
| :warning: | There're library changes, but not tests. That's OK as long as you're refactoring existing code. |
| :warning: | Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md. |
Here's an example of a CHANGELOG.md entry:
* [#2167](https://github.com/ruby-grape/grape/pull/2167): Handle the changes in errors method in rails 6.1 - [@abo-elleef](https://github.com/abo-elleef).
Generated by :no_entry_sign: Danger
Thanks. At the very least this needs an integration test.
I don't like that we're checking against a Rails type. Maybe these objects respond_to?(:something) which can make this cleaner. Or we need to extend the implementation with a proper Railtie.
Another thought, since User.first.errors.messages is producing the exception, maybe the "right way" is to avoid the exception altogether?