errorMapping
定义为:
[[[[RKObjectManager sharedManager] mappingProvider] errorMapping] setRootKeyPath:@"error"];
它适用于简单的错误消息作为字符串:
render status: :unprocessable_entity, json: { :error => 'cannot create topic' }
但是,哈希响应失败:
render status: :unprocessable_entity, json: { :error => @topic.errors }
并给出:
W restkit.object_mapping:RKObjectMappingOperation.m:239:-[RKObjectMappingOperation transformValue:atKeyPath:toType:] keyPath''处的值转换失败。没有从“JKDictionary”转换为“NSString”的策略
有没有办法将 RestKit 配置errorMapping
为接受哈希响应(并希望存储在 中NSDictionary
)?