首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >#<FastJsonapi::MandatoryField: id是jsonapi spec>中的必填字段

#<FastJsonapi::MandatoryField: id是jsonapi spec>中的必填字段
EN

Stack Overflow用户
提问于 2019-03-19 20:58:49
回答 1查看 3.6K关注 0票数 2

当尝试将枚举对象传递给序列化程序时,我得到以下错误:

#<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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55241646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档