The RKRailsRouter no longer sends params with delete requests.

The RKObjectLoader will now clean up deleted objects inside of processLoadModelsInBackground:
This commit is contained in:
Jeremy Ellison
2011-01-06 15:47:09 -05:00
parent b31e6426a5
commit f690fa19f3
2 changed files with 11 additions and 2 deletions

View File

@@ -169,8 +169,12 @@
if (self.targetObject) {
if (_targetObjectID) {
NSManagedObject* backgroundThreadModel = [self.managedObjectStore objectWithID:_targetObjectID];
[_mapper mapObject:backgroundThreadModel fromString:[response bodyAsString]];
results = [NSArray arrayWithObject:backgroundThreadModel];
if (self.method == RKRequestMethodDELETE) {
[[objectStore managedObjectContext] deleteObject:backgroundThreadModel];
} else {
[_mapper mapObject:backgroundThreadModel fromString:[response bodyAsString]];
results = [NSArray arrayWithObject:backgroundThreadModel];
}
} else {
[_mapper mapObject:self.targetObject fromString:[response bodyAsString]];
results = [NSArray arrayWithObject:self.targetObject];

View File

@@ -44,6 +44,11 @@
#pragma mark RKRouter
- (NSObject<RKRequestSerializable>*)serializationForObject:(NSObject<RKObjectMappable>*)object method:(RKRequestMethod)method {
// Rails does not send parameters for delete requests.
if (method == RKRequestMethodDELETE) {
return nil;
}
NSDictionary* elementsAndProperties = [self elementNamesAndPropertyValuesForObject:object];
NSMutableDictionary* resourceParams = [NSMutableDictionary dictionaryWithCapacity:[elementsAndProperties count]];
NSString* modelName = [_classToModelMappings objectForKey:[object class]];