2

尝试将枚举对象传递给序列化程序时,出现以下错误:

#<FastJsonapi::MandatoryField: id is a mandatory field in the jsonapi spec>

@drop_down_values = Organisation.ownerships 其中@drop_down_values 具有所有权列中的枚举值。

render json: DropDownValueSerializer.new(@drop_down_values).serialized_json

4

1 回答 1

0

我默认找到了那个FastJsonAPI expects对象id。因此,当将对象传递给它时,serializer它期望id出现在传递的对象中。

' https://github.com/Netflix/fast_jsonapi/issues/100 ' 这已在 FastJsonAPI 中记录为问题。

以下工作正常: render json: DropDownValueSerializer.new(Organisation.first).serialized_json

于 2019-03-19T12:58:49.080 回答