Serializing the errors hash in ActiveModel::Serializer

后端 未结 4 1156
囚心锁ツ
囚心锁ツ 2021-02-08 13:45

I\'m using ActiveModel::Serializer to customize the JSON responses for my API. This works fine in most cases, except when it fails to save a model successfully.

For exa

4条回答
  •  抹茶落季
    2021-02-08 14:19

    The class name of resource.errors is ActiveModel::Errors so you have to define you class as ActiveModel::ErrorsSerializer.

    Ref: source code

提交回复
热议问题