grape icon indicating copy to clipboard operation
grape copied to clipboard

handle the changes in errors method in rails 6.1

Open abo-elleef opened this issue 4 years ago • 3 comments

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

abo-elleef avatar Mar 12 '21 12:03 abo-elleef

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

grape-bot avatar Mar 12 '21 12:03 grape-bot

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.

dblock avatar Mar 12 '21 16:03 dblock

Another thought, since User.first.errors.messages is producing the exception, maybe the "right way" is to avoid the exception altogether?

dblock avatar Mar 12 '21 16:03 dblock