在测试我的控制器(使用jsonapi-resources)时,在更新时我遇到了这个错误。
{\"errors\":[{\"title\":\"Key is not included in URL\",\"detail\":\"The URL does not support the key 946591862\",\"id\":null,\"href\":null,\"code\":\"110\",\"source\":null,\"links\":null,\"status\":\"400\",\"meta\":null}]}
发出请求的代码示例
process :update, method: :post, params: {
id: model_id,
data: update_attributes
}
我只是编写基本的 ActionController::TestCase 测试。 update_attributes 方法遵循以下格式:
{
id: model_id,
attributes: attributes,
type: model_type
}
啊。我遇到的问题是我在数据哈希内部和外部使用了不同的 id。
感谢您在找到解决方案后在这里发表评论。它确实是一个救星。