Skip to content

Instantly share code, notes, and snippets.

@rayfix
Created Aug 9, 2011
Embed
What would you like to do?
mapping problem ... crud operations
RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class]];
// Core data
//channelMapping.primaryKeyAttribute = "channelID";
// For now using NSObject derived thing
[channelMapping mapKeyPathsToAttributes:
@"id", @"channelID",
@"created_at", @"createdAt",
@"updated_at", @"updatedAt",
@"name", @"name",
@"description", @"description",
@"public", @"isPublic",
nil];
[serializationChannelMapping mapKeyPathsToAttributes:
@"name", @"name",
@"description", @"description",
@"public", @"isPublic",
nil];
[objectManager.mappingProvider setSerializationMapping:serializationChannelMapping forClass:[Channel class]];
[objectManager.mappingProvider setMapping:channelMapping forKeyPath:@"channels"];
// [objectManager.mappingProvider registerMapping:channelMapping withRootKeyPath:@"channel"];
[objectManager.router routeClass:[Channel class] toResourcePath:@"channels" forMethod:RKRequestMethodPOST];
[objectManager.router routeClass:[Channel class] toResourcePath:@"channels/(channelID)" forMethod:RKRequestMethodGET];
[objectManager.router routeClass:[Channel class] toResourcePath:@"channels/(channelID)" forMethod:RKRequestMethodDELETE];
[objectManager.router routeClass:[Channel class] toResourcePath:@"channels/(channelID)" forMethod:RKRequestMethodPUT];
@rayfix
Copy link
Author

rayfix commented Aug 9, 2011

when I try to POST a new one I get

2011-08-09 14:24:23.895 TestApp[31268:207] D restkit.network:RKRequest.m:257 Sending asynchronous POST request to URL http://localhost:3000/api/v1/channels.
2011-08-09 14:24:23.895 TestApp[31268:207] D restkit.network:RKObjectLoader.m:290 POST or PUT request for source object test description, serializing to MIME Type application/json for transport...
2011-08-09 14:24:23.895 TestApp[31268:207] D restkit.object_mapping:RKObjectMappingOperation.m:428 Starting mapping operation...
2011-08-09 14:24:23.896 TestApp[31268:207] D restkit.object_mapping:RKObjectMappingOperation.m:434 Finished mapping operation successfully...
2011-08-09 14:24:23.896 TestApp[31268:207] D restkit.network.queue:RKRequestQueue.m:187 Sent request <RKObjectLoader: 0x65d0b60> from queue <RKRequestQueue: 0x6370190>. Loading count = 1 of 5
2011-08-09 14:24:24.706 TestApp[31268:207] D restkit.network:RKResponse.m:182 NSHTTPURLResponse Status Code: 422
2011-08-09 14:24:24.707 TestApp[31268:207] D restkit.network:RKResponse.m:183 Headers: {
"Cache-Control" = "no-cache";
Connection = "Keep-Alive";
"Content-Length" = 27;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 09 Aug 2011 21:24:24 GMT";
Location = "http://localhost:3000/api/v1/channels";
Server = "WEBrick/1.3.1 (Ruby/1.9.2/2010-12-25)";
"X-Runtime" = "0.791108";
"X-Ua-Compatible" = "IE=Edge";
}
2011-08-09 14:24:24.707 TestApp[31268:207] D restkit.object_mapping:RKObjectMapper.m:240 Performing object mapping sourceObject: {
name = (
"can't be blank"
);
}
and targetObject: (null)
2011-08-09 14:24:24.707 TestApp[31268:207] D restkit.object_mapping:RKObjectMapper.m:264 Found unmappable value at keyPath: errors
2011-08-09 14:24:24.708 TestApp[31268:207] D restkit.object_mapping:RKObjectMapper.m:264 Found unmappable value at keyPath: channels
2011-08-09 14:24:24.708 TestApp[31268:207] D restkit.object_mapping:RKObjectMapper.m:264 Found unmappable value at keyPath: error
2011-08-09 14:24:24.708 TestApp[31268:207] W restkit.object_mapping:RKObjectMapper.m:60 Adding mapping error: Could not find an object mapping for keyPath: ''
2011-08-09 14:24:24.708 TestApp[31268:207] E restkit.network:RKObjectLoader.m:178 Encountered errors during mapping: Could not find an object mapping for keyPath: ''
2011-08-09 14:24:24.708 TestApp[31268:207] E restkit.network:RKObjectLoader.m:277 Encountered an error while attempting to map server side errors from payload: Could not find an object mapping for keyPath: ''
2011-08-09 14:24:24.709 TestApp[31268:207] TestApp Payload: {"name":["can't be blank"]}
2011-08-09 14:24:24.709 TestApp[31268:207] Error: Could not find an object mapping for keyPath: ''
2011-08-09 14:24:24.709 TestApp[31268:207] D restkit.network.queue:RKRequestQueue.m:368 Request <RKObjectLoader: 0x65d0b60> failed loading in queue <RKRequestQueue: 0x6370190> with error: Could not find an object mapping for keyPath: ''.(Now loading 0 of 5)

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment