当尝试将枚举对象传递给序列化程序时,我得到以下错误:
#<FastJsonapi::MandatoryField: id is a mandatory field in the jsonapi spec>
其中@drop_down_values具有所有权列中的枚举值的@drop_down_values = Organisation.ownerships。
render json: DropDownValueSerializer.new(@drop_down_values).serialized_json
发布于 2019-03-19 20:58:49
我在默认情况下找到了FastJsonAPI expects对象id。因此,当将对象传递给serializer时,它希望id出现在传递的对象中。
'https://github.com/Netflix/fast_jsonapi/issues/100‘这已在FastJsonAPI中记录为问题。
下面的代码工作正常:render json: DropDownValueSerializer.new(Organisation.first).serialized_json
https://stackoverflow.com/questions/55241646
复制相似问题